http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiExpectTest.java
----------------------------------------------------------------------
diff --git 
a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiExpectTest.java
 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiExpectTest.java
new file mode 100644
index 0000000..edece18
--- /dev/null
+++ 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiExpectTest.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.ec2.features;
+
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static org.testng.Assert.assertEquals;
+
+import org.jclouds.ec2.EC2Api;
+import org.jclouds.ec2.domain.KeyPair;
+import org.jclouds.ec2.internal.BaseEC2ApiExpectTest;
+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;
+
+@Test(groups = "unit", testName = "KeyPairApiExpectTest")
+public class KeyPairApiExpectTest extends BaseEC2ApiExpectTest<EC2Api> {
+
+   HttpRequest filter = HttpRequest.builder().method("POST")
+           .endpoint("https://ec2.us-east-1.amazonaws.com/";)
+           .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+           .addFormParam("Action", "DescribeKeyPairs")
+           .addFormParam("Filter.1.Name", "key-name")
+           .addFormParam("Filter.1.Value.1", "gsg-keypair")
+           .addFormParam("Signature", 
"xg8vGx%2Bv9UEG0%2BFGy%2BhincdI2ziWLbwPJvW85l%2Bvqwg%3D")
+           .addFormParam("SignatureMethod", "HmacSHA256")
+           .addFormParam("SignatureVersion", "2")
+           .addFormParam("Timestamp", "2012-04-16T15%3A54%3A08.897Z")
+           .addFormParam("Version", "2010-08-31")
+           .addFormParam("AWSAccessKeyId", "identity").build();
+
+   public void testFilterWhenResponseIs2xx() {
+      HttpResponse filterResponse = HttpResponse.builder().statusCode(200)
+              
.payload(payloadFromResourceWithContentType("/describe_keypairs.xml", 
"text/xml")).build();
+
+      EC2Api apiWhenExist = requestsSendResponses(describeRegionsRequest, 
describeRegionsResponse, filter, filterResponse);
+
+      KeyPair keyPair = 
getOnlyElement(apiWhenExist.getKeyPairApi().get().describeKeyPairsInRegionWithFilter("us-east-1",
+              ImmutableMultimap.<String, String>builder()
+                      .put("key-name", "gsg-keypair")
+                      .build()));
+
+      assertEquals(keyPair.getKeyName(), "gsg-keypair");
+   }
+
+   public void testFilterWhenResponseIs404() {
+      HttpResponse filterResponse = 
HttpResponse.builder().statusCode(404).build();
+
+      EC2Api apiWhenNotExist = requestsSendResponses(describeRegionsRequest, 
describeRegionsResponse, filter, filterResponse);
+
+      
assertEquals(apiWhenNotExist.getKeyPairApi().get().describeKeyPairsInRegionWithFilter("us-east-1",
+              ImmutableMultimap.<String, String>builder()
+                      .put("key-name", "gsg-keypair")
+                      .build()),
+              ImmutableSet.of());
+   }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiLiveTest.java
----------------------------------------------------------------------
diff --git 
a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiLiveTest.java
 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiLiveTest.java
new file mode 100644
index 0000000..8f2340f
--- /dev/null
+++ 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiLiveTest.java
@@ -0,0 +1,141 @@
+/*
+ * 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.ec2.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.Set;
+import java.util.SortedSet;
+
+import org.jclouds.aws.AWSResponseException;
+import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
+import org.jclouds.ec2.EC2Api;
+import org.jclouds.ec2.domain.KeyPair;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.Sets;
+
+/**
+ * Tests behavior of {@code KeyPairApi}
+ */
+@Test(groups = "live", singleThreaded = true, testName = "KeyPairApiLiveTest")
+public class KeyPairApiLiveTest extends BaseComputeServiceContextLiveTest {
+   public KeyPairApiLiveTest() {
+      provider = "ec2";
+   }
+
+   private EC2Api ec2Api;
+   private KeyPairApi client;
+   
+   @Override
+   @BeforeClass(groups = { "integration", "live" })
+   public void setupContext() {
+      super.setupContext();
+      ec2Api = view.unwrapApi(EC2Api.class);
+      client = ec2Api.getKeyPairApi().get();
+   }
+
+   @Test
+   void testDescribeKeyPairs() {
+      for (String region : ec2Api.getConfiguredRegions()) {
+         SortedSet<KeyPair> allResults = 
Sets.newTreeSet(client.describeKeyPairsInRegion(region));
+         assertNotNull(allResults);
+         if (!allResults.isEmpty()) {
+            KeyPair pair = allResults.last();
+            SortedSet<KeyPair> result = 
Sets.newTreeSet(client.describeKeyPairsInRegion(region, pair.getKeyName()));
+            assertNotNull(result);
+            KeyPair compare = result.last();
+            assertEquals(compare, pair);
+         }
+      }
+   }
+
+   @Test
+   void testDescribeKeyPairsWithFilter() {
+      for (String region : ec2Api.getConfiguredRegions()) {
+         SortedSet<KeyPair> allResults = 
Sets.newTreeSet(client.describeKeyPairsInRegion(region));
+         assertNotNull(allResults);
+         if (!allResults.isEmpty()) {
+            KeyPair pair = allResults.last();
+            SortedSet<KeyPair> result = 
Sets.newTreeSet(client.describeKeyPairsInRegionWithFilter(region,
+                    ImmutableMultimap.<String, String>builder()
+                            .put("key-name", pair.getKeyName()).build()));
+            assertNotNull(result);
+            KeyPair compare = result.last();
+            assertEquals(compare, pair);
+         }
+      }
+   }
+
+   @Test(expectedExceptions = AWSResponseException.class)
+   void testDescribeKeyPairsWithInvalidFilter() {
+      for (String region : ec2Api.getConfiguredRegions()) {
+         SortedSet<KeyPair> allResults = 
Sets.newTreeSet(client.describeKeyPairsInRegion(region));
+         assertNotNull(allResults);
+         if (!allResults.isEmpty()) {
+            KeyPair pair = allResults.last();
+            SortedSet<KeyPair> result = 
Sets.newTreeSet(client.describeKeyPairsInRegionWithFilter(region,
+                    ImmutableMultimap.<String, String>builder()
+                            .put("invalid-filter", 
pair.getKeyName()).build()));
+         }
+      }
+   }
+
+   public static final String PREFIX = System.getProperty("user.name") + 
"-ec2";
+
+   @Test
+   void testCreateKeyPair() {
+      String keyName = PREFIX + "1";
+      try {
+         client.deleteKeyPairInRegion(null, keyName);
+      } catch (Exception e) {
+
+      }
+      client.deleteKeyPairInRegion(null, keyName);
+
+      KeyPair result = client.createKeyPairInRegion(null, keyName);
+      assertNotNull(result);
+      assertNotNull(result.getKeyMaterial());
+      assertNotNull(result.getSha1OfPrivateKey());
+      assertEquals(result.getKeyName(), keyName);
+
+      Set<KeyPair> twoResults = 
Sets.newLinkedHashSet(client.describeKeyPairsInRegion(null, keyName));
+      assertNotNull(twoResults);
+      assertEquals(twoResults.size(), 1);
+      KeyPair listPair = twoResults.iterator().next();
+      assertEquals(listPair.getKeyName(), result.getKeyName());
+      assertEquals(listPair.getSha1OfPrivateKey(), 
result.getSha1OfPrivateKey());
+   }
+
+   @AfterClass(groups = { "integration", "live" })
+   @Override
+   protected void tearDownContext() {
+      String keyName = PREFIX + "1";
+      try {
+         client.deleteKeyPairInRegion(null, keyName);
+      } catch (Exception e) {
+
+      }
+
+      super.tearDownContext();
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiTest.java
----------------------------------------------------------------------
diff --git 
a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiTest.java
 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiTest.java
new file mode 100644
index 0000000..532d2c6
--- /dev/null
+++ 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiTest.java
@@ -0,0 +1,86 @@
+/*
+ * 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.ec2.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.ec2.xml.DescribeKeyPairsResponseHandler;
+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 KeyPairApi}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during 
surefire
+@Test(groups = "unit", testName = "KeyPairApiTest")
+public class KeyPairApiTest extends BaseEC2ApiTest<KeyPairApi> {
+
+   public void testDeleteKeyPair() throws SecurityException, 
NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(KeyPairApi.class, 
"deleteKeyPairInRegion", String.class, String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, 
Lists.<Object> newArrayList(null, "mykey"));
+
+      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=DeleteKeyPair&KeyName=mykey",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, 
ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testDescribeKeyPairs() throws SecurityException, 
NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(KeyPairApi.class, 
"describeKeyPairsInRegion", 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=DescribeKeyPairs", 
"application/x-www-form-urlencoded",
+            false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, 
DescribeKeyPairsResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   public void testDescribeKeyPairsArgs() throws SecurityException, 
NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(KeyPairApi.class, 
"describeKeyPairsInRegion", 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=DescribeKeyPairs&KeyName.1=1&KeyName.2=2",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, 
DescribeKeyPairsResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiExpectTest.java
----------------------------------------------------------------------
diff --git 
a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiExpectTest.java
 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiExpectTest.java
new file mode 100644
index 0000000..b9f8cf8
--- /dev/null
+++ 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiExpectTest.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.ec2.features;
+
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static org.testng.Assert.assertEquals;
+
+import org.jclouds.ec2.EC2Api;
+import org.jclouds.ec2.domain.SecurityGroup;
+import org.jclouds.ec2.internal.BaseEC2ApiExpectTest;
+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;
+
+@Test(groups = "unit", testName = "SecurityGroupApiExpectTest")
+public class SecurityGroupApiExpectTest extends BaseEC2ApiExpectTest<EC2Api> {
+
+   HttpRequest filter = HttpRequest.builder().method("POST")
+           .endpoint("https://ec2.us-east-1.amazonaws.com/";)
+           .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+           .addFormParam("Action", "DescribeSecurityGroups")
+           .addFormParam("Filter.1.Name", "owner-id")
+           .addFormParam("Filter.1.Value.1", "993194456877")
+           .addFormParam("Signature", 
"zk8EEWkG9Hi0bBLPueF9WdTUKapxQqUXgyJTxeZHXBc%3D")
+           .addFormParam("SignatureMethod", "HmacSHA256")
+           .addFormParam("SignatureVersion", "2")
+           .addFormParam("Timestamp", "2012-04-16T15%3A54%3A08.897Z")
+           .addFormParam("Version", "2010-08-31")
+           .addFormParam("AWSAccessKeyId", "identity").build();
+
+   public void testFilterWhenResponseIs2xx() {
+      HttpResponse filterResponse = HttpResponse.builder().statusCode(200)
+              
.payload(payloadFromResourceWithContentType("/describe_securitygroups_extension_single.xml",
 "text/xml")).build();
+
+      EC2Api apiWhenExist = requestsSendResponses(describeRegionsRequest, 
describeRegionsResponse, filter, filterResponse);
+
+      SecurityGroup group = 
getOnlyElement(apiWhenExist.getSecurityGroupApi().get().describeSecurityGroupsInRegionWithFilter("us-east-1",
+              ImmutableMultimap.<String, String>builder()
+                      .put("owner-id", "993194456877")
+                      .build()));
+
+      assertEquals(group.getId(), "sg-3c6ef654");
+   }
+
+   public void testFilterWhenResponseIs404() {
+      HttpResponse filterResponse = 
HttpResponse.builder().statusCode(404).build();
+
+      EC2Api apiWhenNotExist = requestsSendResponses(describeRegionsRequest, 
describeRegionsResponse, filter, filterResponse);
+
+      
assertEquals(apiWhenNotExist.getSecurityGroupApi().get().describeSecurityGroupsInRegionWithFilter("us-east-1",
+              ImmutableMultimap.<String, String>builder()
+                      .put("owner-id", "993194456877")
+                      .build()),
+              ImmutableSet.of());
+   }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiLiveTest.java
----------------------------------------------------------------------
diff --git 
a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiLiveTest.java
 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiLiveTest.java
new file mode 100644
index 0000000..9318975
--- /dev/null
+++ 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiLiveTest.java
@@ -0,0 +1,332 @@
+/*
+ * 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.ec2.features;
+
+import static com.google.common.base.Predicates.compose;
+import static com.google.common.base.Predicates.in;
+import static com.google.common.collect.Iterables.all;
+import static com.google.common.collect.Iterables.getLast;
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.jclouds.aws.AWSResponseException;
+import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
+import org.jclouds.ec2.EC2Api;
+import org.jclouds.ec2.domain.SecurityGroup;
+import org.jclouds.ec2.domain.UserIdGroupPair;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.net.domain.IpProtocol;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests behavior of {@code SecurityGroupApi}
+ */
+@Test(groups = "live", singleThreaded = true, testName = 
"SecurityGroupApiLiveTest")
+public class SecurityGroupApiLiveTest extends 
BaseComputeServiceContextLiveTest {
+   public SecurityGroupApiLiveTest() {
+      provider = "ec2";
+   }
+
+   private EC2Api ec2Api;
+   protected SecurityGroupApi client;
+
+   @Override
+   @BeforeClass(groups = { "integration", "live" })
+   public void setupContext() {
+      super.setupContext();
+      ec2Api = view.unwrapApi(EC2Api.class);
+      client = ec2Api.getSecurityGroupApi().get();
+   }
+
+   @Test
+   void testDescribe() {
+      for (String region : ec2Api.getConfiguredRegions()) {
+         Set<SecurityGroup> allResults = 
client.describeSecurityGroupsInRegion(region);
+         assertNotNull(allResults);
+         if (!allResults.isEmpty()) {
+            final SecurityGroup group = getLast(allResults);
+            // in case there are multiple groups with the same name, which is 
the case with VPC
+            ImmutableSet<SecurityGroup> expected = 
FluentIterable.from(allResults)
+                    .filter(new Predicate<SecurityGroup>() {
+                       @Override
+                       public boolean apply(SecurityGroup in) {
+                          return group.getName().equals(in.getName());
+                       }
+                    }).toSet();
+            ImmutableSet<SecurityGroup> result = 
ImmutableSet.copyOf(client.describeSecurityGroupsInRegion(region,
+                    group.getName()));
+            // the above command has a chance of returning less groups than 
the original
+            assertTrue(expected.containsAll(result), "group(s) for name not 
found");
+         }
+      }
+   }
+
+   @Test
+   void testFilter() {
+      for (String region : ec2Api.getConfiguredRegions()) {
+         Set<SecurityGroup> allResults = 
client.describeSecurityGroupsInRegion(region);
+         assertNotNull(allResults);
+         if (!allResults.isEmpty()) {
+            final SecurityGroup group = getLast(allResults);
+            // in case there are multiple groups with the same name, which is 
the case with VPC
+            ImmutableSet<SecurityGroup> expected = 
FluentIterable.from(allResults)
+                    .filter(new Predicate<SecurityGroup>() {
+                       @Override
+                       public boolean apply(SecurityGroup in) {
+                          return group.getName().equals(in.getName());
+                       }
+                    }).toSet();
+            ImmutableSet<SecurityGroup> result = 
ImmutableSet.copyOf(client.describeSecurityGroupsInRegionWithFilter(region,
+                    ImmutableMultimap.<String, String>builder()
+                            .put("group-name", group.getName()).build()));
+            // the above command has a chance of returning less groups than 
the original
+            assertTrue(expected.containsAll(result), "group(s) for name not 
found");
+         }
+      }
+   }
+
+   @Test(expectedExceptions = AWSResponseException.class)
+   void testFilterInvalid() {
+      for (String region : ec2Api.getConfiguredRegions()) {
+         Set<SecurityGroup> allResults = 
client.describeSecurityGroupsInRegion(region);
+         assertNotNull(allResults);
+         if (!allResults.isEmpty()) {
+            final SecurityGroup group = getLast(allResults);
+            // in case there are multiple groups with the same name, which is 
the case with VPC
+            ImmutableSet<SecurityGroup> expected = 
FluentIterable.from(allResults)
+                    .filter(new Predicate<SecurityGroup>() {
+                       @Override
+                       public boolean apply(SecurityGroup in) {
+                          return group.getName().equals(in.getName());
+                       }
+                    }).toSet();
+            ImmutableSet<SecurityGroup> result = 
ImmutableSet.copyOf(client.describeSecurityGroupsInRegionWithFilter(region,
+                    ImmutableMultimap.<String, String>builder()
+                            .put("invalid-filter", group.getName()).build()));
+         }
+      }
+   }
+
+   @Test
+   void testCreateSecurityGroup() {
+      String groupName = PREFIX + "1";
+      cleanupAndSleep(groupName);
+      try {
+         String groupDescription = PREFIX + "1 description";
+         client.deleteSecurityGroupInRegion(null, groupName);
+         client.createSecurityGroupInRegion(null, groupName, groupDescription);
+         verifySecurityGroup(groupName, groupDescription);
+      } finally {
+         client.deleteSecurityGroupInRegion(null, groupName);
+      }
+   }
+
+   protected void cleanupAndSleep(String groupName) {
+      try {
+         client.deleteSecurityGroupInRegion(null, groupName);
+         Thread.sleep(2000);
+      } catch (Exception e) {
+
+      }
+   }
+
+   @Test
+   void testAuthorizeSecurityGroupIngressCidr() {
+      String groupName = PREFIX + "ingress";
+      cleanupAndSleep(groupName);
+      try {
+         client.createSecurityGroupInRegion(null, groupName, groupName);
+         client.authorizeSecurityGroupIngressInRegion(null, groupName, 
IpProtocol.TCP, 80, 80, "0.0.0.0/0");
+         assertEventually(new GroupHasPermission(client, groupName, new 
TCPPort80AllIPs()));
+
+         client.revokeSecurityGroupIngressInRegion(null, groupName, 
IpProtocol.TCP, 80, 80, "0.0.0.0/0");
+         assertEventually(new GroupHasNoPermissions(client, groupName));
+      } finally {
+         client.deleteSecurityGroupInRegion(null, groupName);
+      }
+   }
+
+   @Test
+   void testAuthorizeSecurityGroupIngressSourcePort() {
+      String groupName = PREFIX + "ingress";
+      cleanupAndSleep(groupName);
+      try {
+         client.createSecurityGroupInRegion(null, groupName, groupName);
+         client.authorizeSecurityGroupIngressInRegion(null, groupName, 
IpProtocol.TCP, 80, 80, "0.0.0.0/0");
+         assertEventually(new GroupHasPermission(client, groupName, new 
TCPPort80AllIPs()));
+
+         client.revokeSecurityGroupIngressInRegion(null, groupName, 
IpProtocol.TCP, 80, 80, "0.0.0.0/0");
+         assertEventually(new GroupHasNoPermissions(client, groupName));
+      } finally {
+         client.deleteSecurityGroupInRegion(null, groupName);
+      }
+   }
+
+   private void verifySecurityGroup(String groupName, String description) {
+      Set<SecurityGroup> oneResult = 
client.describeSecurityGroupsInRegion(null, groupName);
+      assertNotNull(oneResult);
+      assertEquals(oneResult.size(), 1);
+      SecurityGroup listPair = oneResult.iterator().next();
+      assertEquals(listPair.getName(), groupName);
+      assertEquals(listPair.getDescription(), description);
+   }
+
+   @Test
+   void testAuthorizeSecurityGroupIngressSourceGroup() {
+      final String group1Name = PREFIX + "ingress1";
+      String group2Name = PREFIX + "ingress2";
+      cleanupAndSleep(group2Name);
+      cleanupAndSleep(group1Name);
+      try {
+         client.createSecurityGroupInRegion(null, group1Name, group1Name);
+         client.createSecurityGroupInRegion(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(),
 group1Name));
+            }
+         }));
+
+         client.revokeSecurityGroupIngressInRegion(null, group2Name,
+               new UserIdGroupPair(group.getOwnerId(), group1Name));
+         assertEventually(new GroupHasNoPermissions(client, group2Name));
+      } finally {
+         client.deleteSecurityGroupInRegion(null, group2Name);
+         client.deleteSecurityGroupInRegion(null, group1Name);
+      }
+   }
+
+   public final class TCPPort80AllIPs implements Predicate<IpPermission> {
+      @Override
+      public boolean apply(IpPermission arg0) {
+         return arg0.getIpProtocol() == IpProtocol.TCP && arg0.getFromPort() 
== 80 && arg0.getToPort() == 80
+               && arg0.getCidrBlocks().equals(ImmutableSet.of("0.0.0.0/0"));
+      }
+   }
+
+   public static final class GroupHasPermission implements Runnable {
+      private final SecurityGroupApi client;
+      private final String group;
+      private final Predicate<IpPermission> permission;
+
+      public GroupHasPermission(SecurityGroupApi client, String group, 
Predicate<IpPermission> permission) {
+         this.client = client;
+         this.group = group;
+         this.permission = permission;
+      }
+
+      public void run() {
+         try {
+            Set<SecurityGroup> oneResult = 
client.describeSecurityGroupsInRegion(null, group);
+            assert all(getOnlyElement(oneResult), permission) : permission
+                  + ": " + oneResult;
+         } catch (Exception e) {
+            throw new AssertionError(e);
+         }
+      }
+   }
+
+   public static final class GroupHasNoPermissions implements Runnable {
+      private final SecurityGroupApi client;
+      private final String group;
+
+      public GroupHasNoPermissions(SecurityGroupApi client, String group) {
+         this.client = client;
+         this.group = group;
+      }
+
+      public void run() {
+         try {
+            Set<SecurityGroup> oneResult = 
client.describeSecurityGroupsInRegion(null, group);
+            assertNotNull(oneResult);
+            assertEquals(oneResult.size(), 1);
+            SecurityGroup listPair = oneResult.iterator().next();
+            assertEquals(listPair.size(), 0);
+         } catch (Exception e) {
+            throw new AssertionError(e);
+         }
+      }
+   }
+
+   protected void ensureGroupsExist(String group1Name, String group2Name) {
+      Set<SecurityGroup> twoResults = 
client.describeSecurityGroupsInRegion(null, group1Name, group2Name);
+      assertNotNull(twoResults);
+      assertTrue(twoResults.size() >= 2);// in VPC could be multiple groups 
with the same name
+
+      assertTrue(all(twoResults, compose(in(ImmutableSet.of(group1Name, 
group2Name)),
+            new Function<SecurityGroup, String>() {
+               @Override
+               public String apply(SecurityGroup in) {
+                  return in.getName();
+               }
+            })));
+   }
+
+   private static final int INCONSISTENCY_WINDOW = 5000;
+
+   /**
+    * Due to eventual consistency, container commands may not return correctly
+    * immediately. Hence, we will try up to the inconsistency window to see if
+    * the assertion completes.
+    */
+   protected static void assertEventually(Runnable assertion) {
+      long start = System.currentTimeMillis();
+      AssertionError error = null;
+      for (int i = 0; i < 30; i++) {
+         try {
+            assertion.run();
+            if (i > 0)
+               System.err.printf("%d attempts and %dms asserting %s%n", i + 1, 
System.currentTimeMillis() - start,
+                     assertion.getClass().getSimpleName());
+            return;
+         } catch (AssertionError e) {
+            error = e;
+         }
+         try {
+            Thread.sleep(INCONSISTENCY_WINDOW / 30);
+         } catch (InterruptedException e) {
+         }
+      }
+      if (error != null)
+         throw error;
+
+   }
+
+   public static final String PREFIX = System.getProperty("user.name") + 
"-ec2";
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiTest.java
----------------------------------------------------------------------
diff --git 
a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiTest.java
 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiTest.java
new file mode 100644
index 0000000..aad6230
--- /dev/null
+++ 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiTest.java
@@ -0,0 +1,234 @@
+/*
+ * 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.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.ec2.domain.UserIdGroupPair;
+import org.jclouds.ec2.xml.DescribeSecurityGroupsResponseHandler;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ReleasePayloadAndReturn;
+import org.jclouds.net.domain.IpProtocol;
+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 SecurityGroupApi}
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during 
surefire
+@Test(groups = "unit", testName = "SecurityGroupApiTest")
+public class SecurityGroupApiTest extends BaseEC2ApiTest<SecurityGroupApi> {
+
+   public void testDeleteSecurityGroup() throws SecurityException, 
NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SecurityGroupApi.class, 
"deleteSecurityGroupInRegion", 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=DeleteSecurityGroup&GroupName=name",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, 
ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, VoidOnNotFoundOr404.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")
+                                                .addFormParam("Signature", 
"msp9zFJLrRXYsVu/vbSZE8tQVS/TEvF0Cu/ldYVFdcA%3D")
+                                                
.addFormParam("SignatureMethod", "HmacSHA256")
+                                                
.addFormParam("SignatureVersion", "2")
+                                                .addFormParam("Timestamp", 
"2009-11-08T15%3A54%3A08.897Z")
+                                                .addFormParam("Version", 
"2010-08-31")
+                                                
.addFormParam("AWSAccessKeyId", "identity").build();
+
+   public void testCreateSecurityGroup() throws SecurityException, 
NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SecurityGroupApi.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, 
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 testDescribeSecurityGroups() throws SecurityException, 
NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SecurityGroupApi.class, 
"describeSecurityGroupsInRegion", 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, 
DescribeSecurityGroupsResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   public void testDescribeSecurityGroupsArgs() throws SecurityException, 
NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SecurityGroupApi.class, 
"describeSecurityGroupsInRegion", 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&GroupName.1=1&GroupName.2=2",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, ParseSax.class);
+      assertSaxResponseParserClassEquals(method, 
DescribeSecurityGroupsResponseHandler.class);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(request);
+   }
+
+   public void testAuthorizeSecurityGroupIngressGroup() throws 
SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SecurityGroupApi.class, 
"authorizeSecurityGroupIngressInRegion", String.class,
+            String.class, UserIdGroupPair.class);
+      GeneratedHttpRequest request = processor.createRequest(method, 
Lists.<Object> newArrayList(null, "group", new UserIdGroupPair("sourceUser",
+            "sourceGroup")));
+
+      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&GroupName=group&SourceSecurityGroupOwnerId=sourceUser&SourceSecurityGroupName=sourceGroup",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, 
ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest authorizeSecurityGroupIngressCidr = 
HttpRequest.builder().method("POST")
+                                                              
.endpoint("https://ec2.us-east-1.amazonaws.com/";)
+                                                              
.addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                                                              
.addFormParam("Action", "AuthorizeSecurityGroupIngress")
+                                                              
.addFormParam("CidrIp", "0.0.0.0/0")
+                                                              
.addFormParam("FromPort", "6000")
+                                                              
.addFormParam("GroupName", "group")
+                                                              
.addFormParam("IpProtocol", "tcp")
+                                                              
.addFormParam("Signature", "xeaZpQ1Lvhp%2BqETpEzOPGHW6isAWYwgtBdCnTqWzkAw%3D")
+                                                              
.addFormParam("SignatureMethod", "HmacSHA256")
+                                                              
.addFormParam("SignatureVersion", "2")
+                                                              
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
+                                                              
.addFormParam("ToPort", "7000")
+                                                              
.addFormParam("Version", "2010-08-31")
+                                                              
.addFormParam("AWSAccessKeyId", "identity").build();
+
+   public void testAuthorizeSecurityGroupIngressCidr() throws 
SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SecurityGroupApi.class, 
"authorizeSecurityGroupIngressInRegion", String.class,
+            String.class, IpProtocol.class, int.class, int.class, 
String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, 
Lists.<Object> newArrayList(null, "group", IpProtocol.TCP, 6000, 7000, 
"0.0.0.0/0"));
+
+      request = (GeneratedHttpRequest) 
request.getFilters().get(0).filter(request);
+      
+      assertRequestLineEquals(request, "POST 
https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
+      assertPayloadEquals(request, 
authorizeSecurityGroupIngressCidr.getPayload().getRawContent().toString(),
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, 
ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   public void testRevokeSecurityGroupIngressGroup() throws SecurityException, 
NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SecurityGroupApi.class, 
"revokeSecurityGroupIngressInRegion", String.class,
+            String.class, UserIdGroupPair.class);
+      GeneratedHttpRequest request = processor.createRequest(method, 
Lists.<Object> newArrayList(null, "group", new UserIdGroupPair("sourceUser",
+            "sourceGroup")));
+
+      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&GroupName=group&SourceSecurityGroupOwnerId=sourceUser&SourceSecurityGroupName=sourceGroup",
+            "application/x-www-form-urlencoded", false);
+
+      assertResponseParserClassEquals(method, request, 
ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, null);
+
+      checkFilters(request);
+   }
+
+   HttpRequest revokeSecurityGroupIngressCidr = 
HttpRequest.builder().method("POST")
+                                                           
.endpoint("https://ec2.us-east-1.amazonaws.com/";)
+                                                           .addHeader("Host", 
"ec2.us-east-1.amazonaws.com")
+                                                           
.addFormParam("Action", "RevokeSecurityGroupIngress")
+                                                           
.addFormParam("CidrIp", "0.0.0.0/0")
+                                                           
.addFormParam("FromPort", "6000")
+                                                           
.addFormParam("GroupName", "group")
+                                                           
.addFormParam("IpProtocol", "tcp")
+                                                           
.addFormParam("Signature", "P5lxCXMwz6FE8Wo79nEMh8clgLDK3rZxCPRTOKssKKQ%3D")
+                                                           
.addFormParam("SignatureMethod", "HmacSHA256")
+                                                           
.addFormParam("SignatureVersion", "2")
+                                                           
.addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z")
+                                                           
.addFormParam("ToPort", "7000")
+                                                           
.addFormParam("Version", "2010-08-31")
+                                                           
.addFormParam("AWSAccessKeyId", "identity").build();
+
+   public void testRevokeSecurityGroupIngressCidr() throws SecurityException, 
NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(SecurityGroupApi.class, 
"revokeSecurityGroupIngressInRegion", String.class,
+            String.class, IpProtocol.class, int.class, int.class, 
String.class);
+      GeneratedHttpRequest request = processor.createRequest(method, 
Lists.<Object> newArrayList(null, "group", IpProtocol.TCP, 6000, 7000, 
"0.0.0.0/0"));
+
+      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, 
revokeSecurityGroupIngressCidr.getPayload().getRawContent().toString(),
+            "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/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiExpectTest.java
----------------------------------------------------------------------
diff --git 
a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiExpectTest.java
 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiExpectTest.java
new file mode 100644
index 0000000..e36bf9e
--- /dev/null
+++ 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiExpectTest.java
@@ -0,0 +1,116 @@
+/*
+ * 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.ec2.features;
+import static org.testng.Assert.assertEquals;
+
+import java.util.Properties;
+
+import org.jclouds.Constants;
+import org.jclouds.ec2.EC2Api;
+import org.jclouds.ec2.internal.BaseEC2ApiExpectTest;
+import org.jclouds.ec2.parse.DescribeSubnetsResponseTest;
+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;
+
+@Test(groups = "unit")
+public class SubnetApiExpectTest extends BaseEC2ApiExpectTest<EC2Api> {
+
+   /**
+    * @see SubnetApi
+    * @see SinceApiVersion
+    */
+   protected Properties setupProperties() {
+      Properties props = super.setupProperties();
+      props.put(Constants.PROPERTY_API_VERSION, "2011-01-01");
+      return props;
+   }
+   
+   HttpRequest list = HttpRequest.builder().method("POST")
+                                 
.endpoint("https://ec2.us-east-1.amazonaws.com/";)
+                                 .addHeader("Host", 
"ec2.us-east-1.amazonaws.com")
+                                 .addFormParam("Action", "DescribeSubnets")
+                                 .addFormParam("Signature", 
"Uuafp9lnYQmMUcf/JE1epPTQVCSMPqfns%2BwlZssUsi4%3D")
+                                 .addFormParam("SignatureMethod", "HmacSHA256")
+                                 .addFormParam("SignatureVersion", "2")
+                                 .addFormParam("Timestamp", 
"2012-04-16T15%3A54%3A08.897Z")
+                                 .addFormParam("Version", "2011-01-01")
+                                 .addFormParam("AWSAccessKeyId", "identity")
+                                 .build();
+   
+   public void testListWhenResponseIs2xx() throws Exception {
+
+      HttpResponse listResponse = HttpResponse.builder().statusCode(200)
+            
.payload(payloadFromResourceWithContentType("/describe_subnets.xml", 
"text/xml")).build();
+
+      EC2Api apiWhenExist = requestSendsResponse(
+            list, listResponse);
+
+      assertEquals(apiWhenExist.getSubnetApi().get().list().toString(), new 
DescribeSubnetsResponseTest().expected().toString());
+   }
+
+   public void testListWhenResponseIs404() throws Exception {
+
+      HttpResponse listResponse = 
HttpResponse.builder().statusCode(404).build();
+
+      EC2Api apiWhenDontExist = requestSendsResponse(
+            list, listResponse);
+
+      assertEquals(apiWhenDontExist.getSubnetApi().get().list().toSet(), 
ImmutableSet.of());
+   }
+   
+   HttpRequest filter = HttpRequest.builder().method("POST")
+                                   
.endpoint("https://ec2.us-east-1.amazonaws.com/";)
+                                   .addHeader("Host", 
"ec2.us-east-1.amazonaws.com")
+                                   .addFormParam("Action", "DescribeSubnets")
+                                   .addFormParam("Filter.1.Name", "subnet-id")
+                                   .addFormParam("Filter.1.Value.1", 
"subnet-9d4a7b6c")
+                                   .addFormParam("Signature", 
"%2Bp34YACfLk9km1H3eALnDmrkst9FhJttojVSf7VztLk%3D")
+                                   .addFormParam("SignatureMethod", 
"HmacSHA256")
+                                   .addFormParam("SignatureVersion", "2")
+                                   .addFormParam("Timestamp", 
"2012-04-16T15%3A54%3A08.897Z")
+                                   .addFormParam("Version", "2011-01-01")
+                                   .addFormParam("AWSAccessKeyId", 
"identity").build();
+
+   public void testFilterWhenResponseIs2xx() throws Exception {
+      
+      HttpResponse filterResponse = HttpResponse.builder().statusCode(200)
+               
.payload(payloadFromResourceWithContentType("/describe_subnets.xml", 
"text/xml")).build();
+
+      EC2Api apiWhenExist = requestSendsResponse(filter, filterResponse);
+
+      
assertEquals(apiWhenExist.getSubnetApi().get().filter(ImmutableMultimap.<String,
 String> builder()
+                                                         .put("subnet-id", 
"subnet-9d4a7b6c")
+                                                         .build()).toString(),
+               new DescribeSubnetsResponseTest().expected().toString());
+   }
+   
+   public void testFilterWhenResponseIs404() throws Exception {
+
+      HttpResponse filterResponse = 
HttpResponse.builder().statusCode(404).build();
+
+      EC2Api apiWhenDontExist = requestSendsResponse(filter, filterResponse);
+
+      
assertEquals(apiWhenDontExist.getSubnetApi().get().filter(ImmutableMultimap.<String,
 String> builder()
+                                                                
.put("subnet-id", "subnet-9d4a7b6c")
+                                                                
.build()).toSet(), ImmutableSet.of());
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiLiveTest.java
----------------------------------------------------------------------
diff --git 
a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiLiveTest.java
 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiLiveTest.java
new file mode 100644
index 0000000..ee3859b
--- /dev/null
+++ 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiLiveTest.java
@@ -0,0 +1,81 @@
+/*
+ * 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.ec2.features;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static java.lang.String.format;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.logging.Logger.getAnonymousLogger;
+import static org.jclouds.util.Predicates2.retry;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.ec2.domain.Subnet;
+import org.jclouds.ec2.internal.BaseEC2ApiLiveTest;
+import org.jclouds.ec2.util.SubnetFilterBuilder;
+import org.testng.SkipException;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * tests ability to list/filter subnets
+ */
+@Test(groups = "live")
+public class SubnetApiLiveTest extends BaseEC2ApiLiveTest {
+    
+    private void checkSubnet(Subnet subnet) {
+        getAnonymousLogger().info(format("subnet %s vpc: %s", 
subnet.getSubnetId(), subnet.getVpcId()));
+        
+        checkNotNull(subnet.getSubnetId(), "Id: Subnet %s", subnet);
+        checkNotNull(subnet.getVpcId(), "VPC: Subnet %s", subnet);
+        checkNotNull(subnet.getSubnetState(), "SubnetState: Subnet %s", 
subnet);
+        checkNotNull(subnet.getCidrBlock(), "CIDR Block: %s", subnet);
+        checkNotNull(subnet.getAvailabilityZone(), "Availability Zone: %s", 
subnet);
+    }
+    
+    @Test
+    public void testListSubnets() {
+        ImmutableSet<Subnet> subnets = api().list().toSet();
+        getAnonymousLogger().info("subnets: " + subnets.size());
+        
+        for (Subnet subnet : subnets) {
+            checkSubnet(subnet);
+            assertEquals(api().filter(new 
SubnetFilterBuilder().subnetId(subnet.getSubnetId()).build()).get(0), subnet);
+      }
+    }
+
+    @Test
+    public void testFilterWhenNotFound() {
+        assertTrue(retry(new Predicate<Iterable<Subnet>>() {
+                    public boolean apply(Iterable<Subnet> input) {
+                        return api().filter(new 
SubnetFilterBuilder().subnetId("subnet-pants").build())
+                            .toSet().equals(input);
+                    }
+                }, 600, 200, 200, MILLISECONDS).apply(ImmutableSet.<Subnet> 
of()));
+    }
+
+    private SubnetApi api() {
+        Optional<? extends SubnetApi> subnetOption = api.getSubnetApi();
+        if (!subnetOption.isPresent())
+            throw new SkipException("subnet api not present");
+        return subnetOption.get();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/TagApiExpectTest.java
----------------------------------------------------------------------
diff --git 
a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/TagApiExpectTest.java
 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/TagApiExpectTest.java
new file mode 100644
index 0000000..880b650
--- /dev/null
+++ 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/TagApiExpectTest.java
@@ -0,0 +1,282 @@
+/*
+ * 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.ec2.features;
+import static org.testng.Assert.assertEquals;
+
+import java.util.Properties;
+
+import org.jclouds.Constants;
+import org.jclouds.ec2.EC2Api;
+import org.jclouds.ec2.internal.BaseEC2ApiExpectTest;
+import org.jclouds.ec2.parse.DescribeTagsResponseTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+
+@Test(groups = "unit")
+public class TagApiExpectTest extends BaseEC2ApiExpectTest<EC2Api> {
+
+   /**
+    * @see TagApi
+    * @see SinceApiVersion
+    */
+   protected Properties setupProperties() {
+      Properties props = super.setupProperties();
+      props.put(Constants.PROPERTY_API_VERSION, "2010-08-31");
+      return props;
+   }
+   
+   HttpRequest apply = HttpRequest.builder()
+            .method("POST")
+            .endpoint("https://ec2.us-east-1.amazonaws.com/";)
+            .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+            .payload(
+                payloadFromStringWithContentType(
+                        "Action=CreateTags" +
+                        "&ResourceId.1=i-43532" +
+                        
"&Signature=Trp5e5%2BMqeBeBZbLYa9s9gxahQ9nkx6ETfsGl82IV8Y%3D" +
+                        "&SignatureMethod=HmacSHA256" +
+                        "&SignatureVersion=2" +
+                        "&Tag.1.Key=tag" +
+                        "&Tag.1.Value=" +
+                        "&Timestamp=2012-04-16T15%3A54%3A08.897Z" +
+                        "&Version=2010-08-31" +
+                        "&AWSAccessKeyId=identity",
+                     "application/x-www-form-urlencoded"))
+            .build();
+
+   public void testApplyWhenResponseIs2xx() throws Exception {
+
+      HttpResponse applyResponse = 
HttpResponse.builder().statusCode(200).build();
+
+      EC2Api apiWhenExist = requestSendsResponse(apply, applyResponse);
+
+      apiWhenExist.getTagApi().get().applyToResources(ImmutableSet.of("tag"), 
ImmutableSet.of("i-43532"));
+   }
+
+   @Test(expectedExceptions = ResourceNotFoundException.class)
+   public void testApplyWhenResponseIs404() throws Exception {
+
+      HttpResponse applyResponse = 
HttpResponse.builder().statusCode(404).build();
+
+      EC2Api apiWhenDontExist = requestSendsResponse(apply, applyResponse);
+
+      
apiWhenDontExist.getTagApi().get().applyToResources(ImmutableSet.of("tag"), 
ImmutableSet.of("i-43532"));
+   }
+   
+   HttpRequest applyWithValues = HttpRequest.builder()
+            .method("POST")
+            .endpoint("https://ec2.us-east-1.amazonaws.com/";)
+            .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+            .payload(
+               payloadFromStringWithContentType(
+                        "Action=CreateTags" +
+                        "&ResourceId.1=i-43532" +
+                        
"&Signature=jwCQr50j%2BvGkav4t0BN0G8RmNJ7VaFK6/7N/HKUmHL8%3D" +
+                        "&SignatureMethod=HmacSHA256" +
+                        "&SignatureVersion=2" +
+                        "&Tag.1.Key=tag" +
+                        "&Tag.1.Value=value" +
+                        "&Timestamp=2012-04-16T15%3A54%3A08.897Z" +
+                        "&Version=2010-08-31" +
+                        "&AWSAccessKeyId=identity",
+                     "application/x-www-form-urlencoded"))
+            .build();
+
+   public void testApplyWithValuesWhenResponseIs2xx() throws Exception {
+
+      HttpResponse applyResponse = 
HttpResponse.builder().statusCode(200).build();
+
+      EC2Api apiWhenExist = requestSendsResponse(applyWithValues, 
applyResponse);
+
+      apiWhenExist.getTagApi().get().applyToResources(ImmutableMap.of("tag", 
"value"), ImmutableSet.of("i-43532"));
+   }
+
+   @Test(expectedExceptions = ResourceNotFoundException.class)
+   public void testApplyWithValuesWhenResponseIs404() throws Exception {
+
+      HttpResponse applyResponse = 
HttpResponse.builder().statusCode(404).build();
+
+      EC2Api apiWhenDontExist = requestSendsResponse(applyWithValues, 
applyResponse);
+
+      
apiWhenDontExist.getTagApi().get().applyToResources(ImmutableMap.of("tag", 
"value"), ImmutableSet.of("i-43532"));
+   }
+   
+   HttpRequest list = HttpRequest.builder()
+                                       .method("POST")
+                                       
.endpoint("https://ec2.us-east-1.amazonaws.com/";)
+                                       .addHeader("Host", 
"ec2.us-east-1.amazonaws.com")
+                                       .payload(
+                                          payloadFromStringWithContentType(
+                                                   "Action=DescribeTags" +
+                                                   
"&Signature=DYUjPGiRl9copBtmpocMZYVAy4OTrK2AJzcAH5QiBuw%3D" +
+                                                   
"&SignatureMethod=HmacSHA256" +
+                                                   "&SignatureVersion=2" +
+                                                   
"&Timestamp=2012-04-16T15%3A54%3A08.897Z" +
+                                                   "&Version=2010-08-31" +
+                                                   "&AWSAccessKeyId=identity",
+                                                
"application/x-www-form-urlencoded"))
+                                       .build();
+   
+   public void testListWhenResponseIs2xx() throws Exception {
+
+      HttpResponse listResponse = HttpResponse.builder().statusCode(200)
+            .payload(payloadFromResourceWithContentType("/describe_tags.xml", 
"text/xml")).build();
+
+      EC2Api apiWhenExist = requestSendsResponse(
+            list, listResponse);
+
+      assertEquals(apiWhenExist.getTagApi().get().list().toString(), new 
DescribeTagsResponseTest().expected().toString());
+   }
+
+   public void testListWhenResponseIs404() throws Exception {
+
+      HttpResponse listResponse = 
HttpResponse.builder().statusCode(404).build();
+
+      EC2Api apiWhenDontExist = requestSendsResponse(
+            list, listResponse);
+
+      assertEquals(apiWhenDontExist.getTagApi().get().list().toSet(), 
ImmutableSet.of());
+   }
+   
+   HttpRequest filter =
+         HttpRequest.builder()
+                    .method("POST")
+                    .endpoint("https://ec2.us-east-1.amazonaws.com/";)
+                    .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+                    .payload(payloadFromStringWithContentType(
+                                               "Action=DescribeTags" +
+                                               "&Filter.1.Name=resource-type" +
+                                               "&Filter.1.Value.1=instance" +
+                                               "&Filter.2.Name=key" +
+                                               "&Filter.2.Value.1=stack" +
+                                               
"&Signature=doNEEZHEzXV/SD2eSZ6PpB1PADcsAF99lXGvsh3MbS4%3D" +
+                                               "&SignatureMethod=HmacSHA256" +
+                                               "&SignatureVersion=2" +
+                                               
"&Timestamp=2012-04-16T15%3A54%3A08.897Z" +
+                                               "&Version=2010-08-31" +
+                                               "&AWSAccessKeyId=identity",
+                                         "application/x-www-form-urlencoded"))
+                    .build();   
+
+   public void testFilterWhenResponseIs2xx() throws Exception {
+      
+      HttpResponse filterResponse = HttpResponse.builder().statusCode(200)
+               
.payload(payloadFromResourceWithContentType("/describe_tags.xml", 
"text/xml")).build();
+
+      EC2Api apiWhenExist = requestSendsResponse(filter, filterResponse);
+
+      
assertEquals(apiWhenExist.getTagApi().get().filter(ImmutableMultimap.<String, 
String> builder()
+                                                         .put("resource-type", 
"instance")
+                                                         .put("key", "stack")
+                                                         .build()).toString(),
+               new DescribeTagsResponseTest().expected().toString());
+   }
+   
+   public void testFilterWhenResponseIs404() throws Exception {
+
+      HttpResponse filterResponse = 
HttpResponse.builder().statusCode(404).build();
+
+      EC2Api apiWhenDontExist = requestSendsResponse(filter, filterResponse);
+
+      
assertEquals(apiWhenDontExist.getTagApi().get().filter(ImmutableMultimap.<String,
 String> builder()
+            .put("resource-type", "instance")
+            .put("key", "stack")
+            .build()).toSet(), ImmutableSet.of());
+   }
+   
+   HttpRequest delete = HttpRequest.builder()
+            .method("POST")
+            .endpoint("https://ec2.us-east-1.amazonaws.com/";)
+            .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+            .payload(
+               payloadFromStringWithContentType(
+                        "Action=DeleteTags" +
+                        "&ResourceId.1=i-43532" +
+                        
"&Signature=ytM605menR00re60wXMgBDpozrQCi0lVupf755/Mpck%3D" +
+                        "&SignatureMethod=HmacSHA256" +
+                        "&SignatureVersion=2" +
+                        "&Tag.1.Key=tag" +
+                        "&Timestamp=2012-04-16T15%3A54%3A08.897Z" +
+                        "&Version=2010-08-31" +
+                        "&AWSAccessKeyId=identity",
+                     "application/x-www-form-urlencoded"))
+            .build();
+
+   public void testDeleteWhenResponseIs2xx() throws Exception {
+
+      HttpResponse deleteResponse = 
HttpResponse.builder().statusCode(200).build();
+
+      EC2Api apiWhenExist = requestSendsResponse(delete, deleteResponse);
+
+      
apiWhenExist.getTagApi().get().deleteFromResources(ImmutableSet.of("tag"), 
ImmutableSet.of("i-43532"));
+   }
+
+   @Test(expectedExceptions = ResourceNotFoundException.class)
+   public void testDeleteWhenResponseIs404() throws Exception {
+
+      HttpResponse deleteResponse = 
HttpResponse.builder().statusCode(404).build();
+
+      EC2Api apiWhenDontExist = requestSendsResponse(delete, deleteResponse);
+
+      
apiWhenDontExist.getTagApi().get().deleteFromResources(ImmutableSet.of("tag"), 
ImmutableSet.of("i-43532"));
+   }
+   
+   
+   HttpRequest conditionallyDelete = HttpRequest.builder()
+            .method("POST")
+            .endpoint("https://ec2.us-east-1.amazonaws.com/";)
+            .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+            .payload(
+               payloadFromStringWithContentType(
+                        "Action=DeleteTags" +
+                        "&ResourceId.1=i-43532" +
+                        
"&Signature=vRvgPegVDDjIEKudZ5Tpck0GQrVts//1jzk4W5RgI9k%3D" +
+                        "&SignatureMethod=HmacSHA256" +
+                        "&SignatureVersion=2" +
+                        "&Tag.1.Key=tag" +
+                        "&Tag.1.Value=value" +
+                        "&Timestamp=2012-04-16T15%3A54%3A08.897Z" +
+                        "&Version=2010-08-31" +
+                        "&AWSAccessKeyId=identity",
+                     "application/x-www-form-urlencoded"))
+            .build();
+
+   public void testConditionallyDeleteWhenResponseIs2xx() throws Exception {
+
+      HttpResponse conditionallyDeleteResponse = 
HttpResponse.builder().statusCode(200).build();
+
+      EC2Api apiWhenExist = requestSendsResponse(conditionallyDelete, 
conditionallyDeleteResponse);
+
+      
apiWhenExist.getTagApi().get().conditionallyDeleteFromResources(ImmutableMap.of("tag",
 "value"), ImmutableSet.of("i-43532"));
+   }
+
+   @Test(expectedExceptions = ResourceNotFoundException.class)
+   public void testConditionallyDeleteWhenResponseIs404() throws Exception {
+
+      HttpResponse conditionallyDeleteResponse = 
HttpResponse.builder().statusCode(404).build();
+
+      EC2Api apiWhenDontExist = requestSendsResponse(conditionallyDelete, 
conditionallyDeleteResponse);
+
+      
apiWhenDontExist.getTagApi().get().conditionallyDeleteFromResources(ImmutableMap.of("tag",
 "value"), ImmutableSet.of("i-43532"));
+   }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiExpectTest.java
----------------------------------------------------------------------
diff --git 
a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiExpectTest.java
 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiExpectTest.java
new file mode 100644
index 0000000..bd60cdd
--- /dev/null
+++ 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiExpectTest.java
@@ -0,0 +1,112 @@
+/*
+ * 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.ec2.features;
+
+import static com.google.common.collect.Iterables.getOnlyElement;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+
+import org.jclouds.ec2.EC2Api;
+import org.jclouds.ec2.domain.BundleTask;
+import org.jclouds.ec2.internal.BaseEC2ApiExpectTest;
+import org.jclouds.ec2.parse.GetPasswordDataResponseTest;
+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;
+
+@Test(groups = "unit", testName = "WindowsApiExpectTest")
+public class WindowsApiExpectTest extends BaseEC2ApiExpectTest<EC2Api> {
+
+   HttpRequest get = HttpRequest.builder()
+                                .method("POST")
+                                
.endpoint("https://ec2.us-east-1.amazonaws.com/";)
+                                .addHeader("Host", 
"ec2.us-east-1.amazonaws.com")
+                                .payload(
+                                   payloadFromStringWithContentType(
+                                         "Action=GetPasswordData" +
+                                               "&InstanceId=i-2574e22a" +
+                                               
"&Signature=PMr4kU4p%2BSF2ISHXAFUme1kNh%2BCqftIUQchuw3vhKCw%3D" +
+                                               "&SignatureMethod=HmacSHA256" +
+                                               "&SignatureVersion=2" +
+                                               
"&Timestamp=2012-04-16T15%3A54%3A08.897Z" +
+                                               "&Version=2010-08-31" +
+                                               "&AWSAccessKeyId=identity",
+                                         "application/x-www-form-urlencoded"))
+                                .build();
+
+   HttpRequest filter = HttpRequest.builder().method("POST")
+           .endpoint("https://ec2.us-east-1.amazonaws.com/";)
+           .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+           .addFormParam("Action", "DescribeBundleTasks")
+           .addFormParam("Filter.1.Name", "instance-id")
+           .addFormParam("Filter.1.Value.1", "i-12345678")
+           .addFormParam("Signature", 
"y0y3UBUKU/uYwbWPTCbkXzprU%2B8fMhg5LfF%2B5hWU2F4%3D")
+           .addFormParam("SignatureMethod", "HmacSHA256")
+           .addFormParam("SignatureVersion", "2")
+           .addFormParam("Timestamp", "2012-04-16T15%3A54%3A08.897Z")
+           .addFormParam("Version", "2010-08-31")
+           .addFormParam("AWSAccessKeyId", "identity").build();
+
+   public void testGetPasswordDataWhenResponseIs2xx() throws Exception {
+
+      HttpResponse getResponse = HttpResponse.builder().statusCode(200)
+            
.payload(payloadFromResourceWithContentType("/get_passworddata.xml", 
"text/xml")).build();
+
+      EC2Api apiWhenExist = requestSendsResponse(get, getResponse);
+
+      
assertEquals(apiWhenExist.getWindowsApi().get().getPasswordDataForInstance("i-2574e22a").toString(),
 new GetPasswordDataResponseTest().expected().toString());
+   }
+
+   public void testGetPasswordDataWhenResponseIs404() throws Exception {
+
+      HttpResponse getResponse = 
HttpResponse.builder().statusCode(404).build();
+
+      EC2Api apiWhenDontExist = requestSendsResponse(get, getResponse);
+
+      
assertNull(apiWhenDontExist.getWindowsApi().get().getPasswordDataForInstance("i-2574e22a"));
+   }
+
+   public void testFilterBundleTasksWhenResponseIs2xx() {
+      HttpResponse filterResponse = HttpResponse.builder().statusCode(200)
+              
.payload(payloadFromResourceWithContentType("/describe_bundle_tasks.xml", 
"text/xml")).build();
+
+      EC2Api apiWhenExist = requestsSendResponses(describeRegionsRequest, 
describeRegionsResponse, filter, filterResponse);
+
+      BundleTask task = 
getOnlyElement(apiWhenExist.getWindowsApi().get().describeBundleTasksInRegionWithFilter("us-east-1",
+              ImmutableMultimap.<String, String>builder()
+                      .put("instance-id", "i-12345678")
+                      .build()));
+
+      assertEquals(task.getBundleId(), "bun-c1a540a8");
+   }
+
+   public void testFilterBundleTasksWhenResponseIs404() {
+      HttpResponse filterResponse = 
HttpResponse.builder().statusCode(404).build();
+
+      EC2Api apiWhenNotExist = requestsSendResponses(describeRegionsRequest, 
describeRegionsResponse, filter, filterResponse);
+
+      
assertEquals(apiWhenNotExist.getWindowsApi().get().describeBundleTasksInRegionWithFilter("us-east-1",
+              ImmutableMultimap.<String, String>builder()
+                      .put("instance-id", "i-12345678")
+                      .build()),
+              ImmutableSet.of());
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/89fab312/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiLiveTest.java
----------------------------------------------------------------------
diff --git 
a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiLiveTest.java
 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiLiveTest.java
new file mode 100644
index 0000000..9baeafc
--- /dev/null
+++ 
b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiLiveTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.ec2.features;
+
+import org.jclouds.ec2.internal.BaseEC2ApiLiveTest;
+import org.testng.SkipException;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+
+@Test(groups = "live")
+public class WindowsApiLiveTest extends BaseEC2ApiLiveTest {
+
+   protected WindowsApi api() {
+      Optional<? extends WindowsApi> windowsOption = api.getWindowsApi();
+      if (!windowsOption.isPresent())
+         throw new SkipException("windows api not present");
+      return windowsOption.get();
+   }
+}

Reply via email to