http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiTest.java deleted file mode 100644 index b5d2d17..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiTest.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * 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} - * - * @author Adrian Cole - */ -// 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/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiExpectTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiExpectTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiExpectTest.java deleted file mode 100644 index 50de812..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiExpectTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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; - -/** - * @author Adrian Cole - */ -@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/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiLiveTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiLiveTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiLiveTest.java deleted file mode 100644 index a9ca1b0..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiLiveTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 - * - * @author Adrian Cole - * @author Andrew Bayer - */ -@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/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/TagApiExpectTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/TagApiExpectTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/TagApiExpectTest.java deleted file mode 100644 index 7ffdb8a..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/TagApiExpectTest.java +++ /dev/null @@ -1,285 +0,0 @@ -/* - * 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; - -/** - * @author Adrian Cole - */ -@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/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiExpectTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiExpectTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiExpectTest.java deleted file mode 100644 index 457b08d..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiExpectTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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; - -/** - * @author Adrian Cole - */ -@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/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiLiveTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiLiveTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiLiveTest.java deleted file mode 100644 index 2cf8257..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiLiveTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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; - -/** - * @author Adrian Cole - */ -@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(); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiTest.java deleted file mode 100644 index d6b44e7..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiTest.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * 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.options.BundleInstanceS3StorageOptions; -import org.jclouds.ec2.xml.BundleTaskHandler; -import org.jclouds.ec2.xml.DescribeBundleTasksResponseHandler; -import org.jclouds.http.HttpRequest; -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 WindowsApi} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "WindowsApiTest") -public class WindowsApiTest extends BaseEC2ApiTest<WindowsApi> { - - HttpRequest bundleInstanceInRegion = HttpRequest.builder().method("POST") - .endpoint("https://ec2.us-east-1.amazonaws.com/") - .addHeader("Host", "ec2.us-east-1.amazonaws.com") - .addFormParam("Action", "BundleInstance") - .addFormParam("InstanceId", "i-e468cd8d") - .addFormParam("Signature", "78A6SjliGJg%2BKzaICB9I4bqEXFoNa4FKonuIwAj9hik%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Storage.S3.Bucket", "my-bucket") - .addFormParam("Storage.S3.Prefix", "winami") - .addFormParam("Storage.S3.UploadPolicy", "eyJleHBpcmF0aW9uIjogIjIwMDgtMDgtMzBUMDg6NDk6MDlaIiwiY29uZGl0aW9ucyI6IFt7ImJ1Y2tldCI6ICJteS1idWNrZXQifSxbInN0YXJ0cy13aXRoIiwgIiRrZXkiLCAibXktbmV3LWltYWdlIl1dfQ%3D%3D") - .addFormParam("Storage.S3.UploadPolicySignature", "ih/iohGe0A7y4QVRbKaq6BZShzUsmBEJEa9AdFbxM6Y%3D") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-08-31") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testBundleInstanceInRegion() throws SecurityException, NoSuchMethodException, IOException { - Invokable<?, ?> method = method(WindowsApi.class, "bundleInstanceInRegion", String.class, String.class, - String.class, String.class, String.class, BundleInstanceS3StorageOptions[].class); - GeneratedHttpRequest request = processor - .createRequest( - method, - Lists.<Object> newArrayList( - null, - "i-e468cd8d", - "winami", - "my-bucket", - "{\"expiration\": \"2008-08-30T08:49:09Z\",\"conditions\": [{\"bucket\": \"my-bucket\"},[\"starts-with\", \"$key\", \"my-new-image\"]]}")); - - 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, bundleInstanceInRegion.getPayload().getRawContent().toString(), - "application/x-www-form-urlencoded", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, BundleTaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - HttpRequest bundleInstanceInRegionOptions = HttpRequest.builder().method("POST") - .endpoint("https://ec2.us-east-1.amazonaws.com/") - .addHeader("Host", "ec2.us-east-1.amazonaws.com") - .addFormParam("Action", "BundleInstance") - .addFormParam("InstanceId","i-e468cd8d") - .addFormParam("Signature", "9UbWwb%2BnO2vHn2O59K9FpmaK445RwX7vXsruHRznwik%3D") - .addFormParam("SignatureMethod", "HmacSHA256") - .addFormParam("SignatureVersion", "2") - .addFormParam("Storage.S3.AWSAccessKeyId", "10QMXFEV71ZS32XQFTR2") - .addFormParam("Storage.S3.Bucket", "my-bucket") - .addFormParam("Storage.S3.Prefix", "winami") - .addFormParam("Storage.S3.UploadPolicy", "eyJleHBpcmF0aW9uIjogIjIwMDgtMDgtMzBUMDg6NDk6MDlaIiwiY29uZGl0aW9ucyI6IFt7ImJ1Y2tldCI6ICJteS1idWNrZXQifSxbInN0YXJ0cy13aXRoIiwgIiRrZXkiLCAibXktbmV3LWltYWdlIl1dfQ%3D%3D") - .addFormParam("Storage.S3.UploadPolicySignature", "ih/iohGe0A7y4QVRbKaq6BZShzUsmBEJEa9AdFbxM6Y%3D") - .addFormParam("Timestamp", "2009-11-08T15%3A54%3A08.897Z") - .addFormParam("Version", "2010-08-31") - .addFormParam("AWSAccessKeyId", "identity").build(); - - public void testBundleInstanceInRegionOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable<?, ?> method = method(WindowsApi.class, "bundleInstanceInRegion", String.class, String.class, - String.class, String.class, String.class, BundleInstanceS3StorageOptions[].class); - GeneratedHttpRequest request = processor - .createRequest( - method, - Lists.<Object> newArrayList( - null, - "i-e468cd8d", - "winami", - "my-bucket", - "{\"expiration\": \"2008-08-30T08:49:09Z\",\"conditions\": [{\"bucket\": \"my-bucket\"},[\"starts-with\", \"$key\", \"my-new-image\"]]}", - BundleInstanceS3StorageOptions.Builder.bucketOwnedBy("10QMXFEV71ZS32XQFTR2"))); - - 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, bundleInstanceInRegionOptions.getPayload().getRawContent().toString(), - "application/x-www-form-urlencoded", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, BundleTaskHandler.class); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - public void testDescribeBundleTasks() throws SecurityException, NoSuchMethodException, IOException { - Invokable<?, ?> method = method(WindowsApi.class, "describeBundleTasksInRegion", 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=DescribeBundleTasks", - "application/x-www-form-urlencoded", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, DescribeBundleTasksResponseHandler.class); - assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testDescribeBundleTasksArgs() throws SecurityException, NoSuchMethodException, IOException { - Invokable<?, ?> method = method(WindowsApi.class, "describeBundleTasksInRegion", 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=DescribeBundleTasks&BundleId.1=1&BundleId.2=2", - "application/x-www-form-urlencoded", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, DescribeBundleTasksResponseHandler.class); - assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class); - - checkFilters(request); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/internal/BaseTagApiLiveTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/internal/BaseTagApiLiveTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/internal/BaseTagApiLiveTest.java deleted file mode 100644 index 9d152b7..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/internal/BaseTagApiLiveTest.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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.internal; - -import static com.google.common.base.Preconditions.checkNotNull; -import static java.util.concurrent.TimeUnit.MILLISECONDS; -import static org.jclouds.util.Predicates2.retry; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - -import java.util.logging.Logger; - -import org.jclouds.ec2.domain.Tag; -import org.jclouds.ec2.features.TagApi; -import org.jclouds.ec2.internal.BaseEC2ApiLiveTest; -import org.jclouds.ec2.util.TagFilterBuilder; -import org.testng.SkipException; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.base.Optional; -import com.google.common.base.Predicate; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -/** - * tests ability to tag, filter, and delete tags from a resource. - * - * @author Adrian Cole - */ -@Test(groups = "live") -public abstract class BaseTagApiLiveTest extends BaseEC2ApiLiveTest { - - private Resource resource; - - private Tag tag; - private Tag tag2; - - public void testApplyTag() { - - api().applyToResources(ImmutableSet.of("foo"), ImmutableSet.of(resource.id)); - - tag = api().filter(new TagFilterBuilder().resourceId(resource.id).key("foo").build()).get(0); - - Logger.getAnonymousLogger().info("created tag: " + tag); - - assertEquals(tag.getKey(), "foo"); - assertEquals(tag.getResourceId(), resource.id); - assertEquals(tag.getResourceType(), resource.type); - assertFalse(tag.getValue().isPresent()); - } - - public void testApplyTagWithValue() { - - api().applyToResources(ImmutableMap.of("type", "bar"), ImmutableSet.of(resource.id)); - - tag2 = api().filter(new TagFilterBuilder().resourceId(resource.id).key("type").build()).get(0); - - Logger.getAnonymousLogger().info("created tag: " + tag2); - - assertEquals(tag2.getKey(), "type"); - assertEquals(tag2.getResourceId(), resource.id); - assertEquals(tag2.getResourceType(), resource.type); - assertEquals(tag2.getValue().get(), "bar"); - } - - @Test(dependsOnMethods = { "testApplyTag", "testApplyTagWithValue" }) - protected void testList() { - assertTrue(retry(new Predicate<Iterable<Tag>>() { - public boolean apply(Iterable<Tag> input) { - return api().list().filter(new Predicate<Tag>() { - @Override - public boolean apply(Tag in) { - return in.getResourceId().equals(resource.id); - } - }).toSet().equals(input); - } - }, 600, 200, 200, MILLISECONDS).apply(ImmutableSet.of(tag, tag2))); - } - - @Test(dependsOnMethods = "testList") - public void testDeleteTags() { - // shouldn't delete with the incorrect values - api().conditionallyDeleteFromResources(ImmutableMap.of(tag.getKey(), "FOO", tag2.getKey(), "FOO"), - ImmutableSet.of(tag.getResourceId(), tag2.getResourceId())); - - assertEquals(tagsForResource().size(), 2); - - api().deleteFromResources(ImmutableSet.of(tag.getKey(), tag2.getKey()), - ImmutableSet.of(tag.getResourceId(), tag2.getResourceId())); - - assertEquals(tagsForResource().size(), 0); - - Logger.getAnonymousLogger().info("tags deleted: " + tag + ", " + tag2); - } - - private FluentIterable<Tag> tagsForResource() { - return api().filter(new TagFilterBuilder().resourceId(resource.id).build()); - } - - @Override - @BeforeClass(groups = "live") - public void setup() { - super.setup(); - resource = checkNotNull(createResourceForTagging(System.getProperty("user.name") + "-tag"), "resource"); - } - - public static class Resource { - public String id; - public String type; - - /** - * - * @param id - * ex. {sg-abc23d} - * @param type - * a type listed in {@link Tag.ResourceType} - */ - public Resource(String id, String type) { - this.id = checkNotNull(id, "id"); - this.type = checkNotNull(type, "type of %s", id); - } - } - - protected abstract Resource createResourceForTagging(String prefix); - - protected abstract void cleanupResource(Resource resource); - - protected TagApi api() { - Optional<? extends TagApi> tagOption = api.getTagApi(); - if (!tagOption.isPresent()) - throw new SkipException("tag api not present"); - return tagOption.get(); - } - - @AfterClass(groups = "live") - protected void tearDown() { - if (resource != null) - cleanupResource(resource); - super.tearDown(); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/functions/ConvertUnencodedBytesToBase64EncodedStringTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/functions/ConvertUnencodedBytesToBase64EncodedStringTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/functions/ConvertUnencodedBytesToBase64EncodedStringTest.java deleted file mode 100644 index 352dae0..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/functions/ConvertUnencodedBytesToBase64EncodedStringTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.functions; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; - -import org.testng.annotations.Test; - -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code ConvertUnencodedBytesToBase64EncodedString} - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public class ConvertUnencodedBytesToBase64EncodedStringTest { - Injector injector = Guice.createInjector(); - - public void testDefault() throws IOException { - ConvertUnencodedBytesToBase64EncodedString function = injector - .getInstance(ConvertUnencodedBytesToBase64EncodedString.class); - - assertEquals("dGVzdA==", function.apply("test".getBytes())); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/functions/EncodedRSAPublicKeyToBase64Test.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/functions/EncodedRSAPublicKeyToBase64Test.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/functions/EncodedRSAPublicKeyToBase64Test.java deleted file mode 100644 index cab55ba..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/functions/EncodedRSAPublicKeyToBase64Test.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.functions; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; - -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code EncodedRSAPublicKeyToBase64} - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public class EncodedRSAPublicKeyToBase64Test { - EncodedRSAPublicKeyToBase64 function = new EncodedRSAPublicKeyToBase64(); - - public void testAllowedMarkers() throws IOException { - assertEquals(function.apply("-----BEGIN CERTIFICATE-----"), "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0t"); - assertEquals(function.apply("ssh-rsa"), "c3NoLXJzYQ=="); - assertEquals(function.apply("---- BEGIN SSH2 PUBLIC KEY ----"), "LS0tLSBCRUdJTiBTU0gyIFBVQkxJQyBLRVkgLS0tLQ=="); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testDisallowedMarkersIllegalArgument() throws IOException { - function.apply("ssh-dsa"); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiExpectTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiExpectTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiExpectTest.java deleted file mode 100644 index 574ef6b..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiExpectTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.internal; - -import java.util.concurrent.atomic.AtomicInteger; - -import org.jclouds.date.DateService; -import org.jclouds.ec2.EC2Api; -import org.jclouds.ec2.config.BaseEC2HttpApiModule; -import org.jclouds.rest.ConfiguresHttpApi; - -import com.google.common.base.Supplier; -import com.google.inject.Module; -import com.google.inject.Provides; -import com.google.inject.TypeLiteral; - -public abstract class BaseEC2ApiExpectTest<T> extends BaseEC2ExpectTest<T> { - - @ConfiguresHttpApi - protected static class TestEC2HttpApiModule extends BaseEC2HttpApiModule<EC2Api> { - - protected TestEC2HttpApiModule() { - super(EC2Api.class); - } - - @Override - protected void configure() { - super.configure(); - // predicatable node names - final AtomicInteger suffix = new AtomicInteger(); - bind(new TypeLiteral<Supplier<String>>() { - }).toInstance(new Supplier<String>() { - - @Override - public String get() { - return suffix.getAndIncrement() + ""; - } - - }); - } - - @Override - @Provides - protected String provideTimeStamp(DateService dateService) { - return CONSTANT_DATE; - } - } - - @Override - protected Module createModule() { - return new TestEC2HttpApiModule(); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiLiveTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiLiveTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiLiveTest.java deleted file mode 100644 index 9ca0c96..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiLiveTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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.internal; - -import org.jclouds.apis.BaseApiLiveTest; -import org.jclouds.ec2.EC2Api; - -/** - * - * @author Adrian Cole - */ -public class BaseEC2ApiLiveTest extends BaseApiLiveTest<EC2Api> { - public BaseEC2ApiLiveTest() { - provider = "ec2"; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ExpectTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ExpectTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ExpectTest.java deleted file mode 100644 index 29808b7..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ExpectTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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.internal; - -import java.util.Map; -import java.util.TimeZone; - -import javax.ws.rs.core.MediaType; - -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.date.DateService; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.rest.internal.BaseRestClientExpectTest; -import org.testng.annotations.BeforeClass; - -import com.google.common.base.Functions; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Injector; - -public abstract class BaseEC2ExpectTest<T> extends BaseRestClientExpectTest<T> { - protected static final String CONSTANT_DATE = "2012-04-16T15:54:08.897Z"; - - protected DateService dateService = new SimpleDateFormatDateService(); - - protected FormSigner formSigner; - - protected HttpRequest describeRegionsRequest; - - protected HttpResponse describeRegionsResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/regionEndpoints-all.xml", MediaType.APPLICATION_XML)) - .build(); - - protected Map<HttpRequest, HttpResponse> describeAvailabilityZonesRequestResponse; - - public BaseEC2ExpectTest() { - provider = "ec2"; - TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); - } - - @BeforeClass - protected void setupDefaultRequests() { - Injector injector = createInjector(Functions.forMap(ImmutableMap.<HttpRequest, HttpResponse> of()), - createModule(), setupProperties()); - formSigner = injector.getInstance(FormSigner.class); - describeRegionsRequest = formSigner.filter(HttpRequest.builder().method("POST") - .endpoint("https://ec2.us-east-1.amazonaws.com/").addHeader("Host", "ec2.us-east-1.amazonaws.com") - .addFormParam("Action", "DescribeRegions").build()); - - Builder<HttpRequest, HttpResponse> builder = ImmutableMap.<HttpRequest, HttpResponse> builder(); - for (String region : ImmutableSet.of("ap-northeast-1", "ap-southeast-1", "eu-west-1", "sa-east-1", "us-east-1", "us-west-1", "us-west-2")) { - builder.put( - formSigner.filter(HttpRequest.builder() - .method("POST") - .endpoint("https://ec2." + region + ".amazonaws.com/") - .addHeader("Host", "ec2." + region + ".amazonaws.com") - .payload(payloadFromStringWithContentType( - "Action=DescribeAvailabilityZones&Version=2010-08-31", - MediaType.APPLICATION_FORM_URLENCODED)).build()), - HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType( - "/availabilityZones-" + region + ".xml", MediaType.APPLICATION_XML)).build()); - - } - describeAvailabilityZonesRequestResponse = builder.build(); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptionsTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptionsTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptionsTest.java deleted file mode 100644 index 5bb07ed..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptionsTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.options; - -import static org.jclouds.ec2.options.BundleInstanceS3StorageOptions.Builder.bucketOwnedBy; -import static org.testng.Assert.assertEquals; - -import org.jclouds.domain.Credentials; -import org.jclouds.http.options.HttpRequestOptions; -import org.testng.annotations.Test; - -import com.google.common.base.Suppliers; -import com.google.common.collect.ImmutableList; - -/** - * Tests possible uses of BundleInstanceS3StorageOptions and - * BundleInstanceS3StorageOptions.Builder.* - * - * @author Adrian Cole - */ -public class BundleInstanceS3StorageOptionsTest { - - @Test - public void testAssignability() { - assert HttpRequestOptions.class.isAssignableFrom(BundleInstanceS3StorageOptions.class); - assert !String.class.isAssignableFrom(BundleInstanceS3StorageOptions.class); - } - - @Test - public void testBucketOwnedBy() { - BundleInstanceS3StorageOptions options = new BundleInstanceS3StorageOptions(); - options.bucketOwnedBy("test"); - assertEquals(options.buildFormParameters().get("Storage.S3.AWSAccessKeyId"), ImmutableList.of("test")); - } - - @Test(expectedExceptions = IllegalStateException.class) - public void testNullBucketOwnedByNotInjected() { - BundleInstanceS3StorageOptions options = new BundleInstanceS3StorageOptions(); - assertEquals(options.buildFormParameters().get("Storage.S3.AWSAccessKeyId"), ImmutableList.of()); - } - - @Test - public void testNullBucketOwnedBy() { - BundleInstanceS3StorageOptions options = new BundleInstanceS3StorageOptions(); - options.creds = Suppliers.ofInstance(new Credentials("foo", null)); - assertEquals(options.buildFormParameters().get("Storage.S3.AWSAccessKeyId"), ImmutableList.of("foo")); - } - - @Test - public void testBucketOwnedByStatic() { - BundleInstanceS3StorageOptions options = bucketOwnedBy("test"); - assertEquals(options.buildFormParameters().get("Storage.S3.AWSAccessKeyId"), ImmutableList.of("test")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testBucketOwnedByNPE() { - bucketOwnedBy(null); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/CreateImageOptionsTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/CreateImageOptionsTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/CreateImageOptionsTest.java deleted file mode 100644 index 8c66ece..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/CreateImageOptionsTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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.options; - -import static org.jclouds.ec2.options.CreateImageOptions.Builder.noReboot; -import static org.jclouds.ec2.options.CreateImageOptions.Builder.withDescription; -import static org.testng.Assert.assertEquals; - -import com.google.common.collect.ImmutableList; - -import org.jclouds.http.options.HttpRequestOptions; -import org.testng.annotations.Test; - -/** - * Tests possible uses of CreateImageOptions and CreateImageOptions.Builder.* - * - * @author Adrian Cole - */ -public class CreateImageOptionsTest { - - @Test - public void testAssignability() { - assert HttpRequestOptions.class.isAssignableFrom(CreateImageOptions.class); - assert !String.class.isAssignableFrom(CreateImageOptions.class); - } - - @Test - public void testWithDescription() { - CreateImageOptions options = new CreateImageOptions(); - options.withDescription("test"); - assertEquals(options.buildFormParameters().get("Description"), - ImmutableList.of("test")); - } - - @Test - public void testNullWithDescription() { - CreateImageOptions options = new CreateImageOptions(); - assertEquals(options.buildFormParameters().get("Description"), ImmutableList.of()); - } - - @Test - public void testWithDescriptionStatic() { - CreateImageOptions options = withDescription("test"); - assertEquals(options.buildFormParameters().get("Description"), - ImmutableList.of("test")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testWithDescriptionNPE() { - withDescription(null); - } - - @Test - public void testNoReboot() { - CreateImageOptions options = new CreateImageOptions(); - options.noReboot(); - assertEquals(options.buildFormParameters().get("NoReboot"), ImmutableList.of("true")); - } - - @Test - public void testNoRebootStatic() { - CreateImageOptions options = noReboot(); - assertEquals(options.buildFormParameters().get("NoReboot"), ImmutableList.of("true")); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/CreateSnapshotOptionsTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/CreateSnapshotOptionsTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/CreateSnapshotOptionsTest.java deleted file mode 100644 index 845b606..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/CreateSnapshotOptionsTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.options; - -import static org.jclouds.ec2.options.CreateSnapshotOptions.Builder.withDescription; -import static org.testng.Assert.assertEquals; - -import com.google.common.collect.ImmutableList; - -import org.jclouds.http.options.HttpRequestOptions; -import org.testng.annotations.Test; - -/** - * Tests possible uses of CreateSnapshotOptions and CreateSnapshotOptions.Builder.* - * - * @author Adrian Cole - */ -public class CreateSnapshotOptionsTest { - - @Test - public void testAssignability() { - assert HttpRequestOptions.class.isAssignableFrom(CreateSnapshotOptions.class); - assert !String.class.isAssignableFrom(CreateSnapshotOptions.class); - } - - @Test - public void testWithDescription() { - CreateSnapshotOptions options = new CreateSnapshotOptions(); - options.withDescription("test"); - assertEquals(options.buildFormParameters().get("Description"), - ImmutableList.of("test")); - } - - @Test - public void testNullWithDescription() { - CreateSnapshotOptions options = new CreateSnapshotOptions(); - assertEquals(options.buildFormParameters().get("Description"), ImmutableList.of()); - } - - @Test - public void testWithDescriptionStatic() { - CreateSnapshotOptions options = withDescription("test"); - assertEquals(options.buildFormParameters().get("Description"), - ImmutableList.of("test")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testWithDescriptionNPE() { - withDescription(null); - } - -}
