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/xml/BundleTaskHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/BundleTaskHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/BundleTaskHandlerTest.java deleted file mode 100644 index 1d56144..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/BundleTaskHandlerTest.java +++ /dev/null @@ -1,68 +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.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.date.DateService; -import org.jclouds.ec2.domain.BundleTask; -import org.jclouds.http.functions.ParseSax; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code BundleTaskHandler} - * - * @author Adrian Cole - */ -//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "BundleTaskHandlerTest") -public class BundleTaskHandlerTest extends BaseEC2HandlerTest { - public void testBundleInstance() { - DateService dateService = injector.getInstance(DateService.class); - InputStream is = getClass().getResourceAsStream("/bundle_instance.xml"); - - BundleTask expected = new BundleTask(defaultRegion, "bun-c1a540a8", null, "i-12345678", 70, dateService - .iso8601DateParse("2008-10-07T11:41:50.000Z"), "bundling", "my-bucket", "winami", dateService - .iso8601DateParse("2008-10-07T11:51:50.000Z")); - - BundleTaskHandler handler = injector.getInstance(BundleTaskHandler.class); - addDefaultRegionToHandler(handler); - BundleTask result = factory.create(handler).parse(is); - - assertEquals(result, expected); - } - - public void testCancleBundleTask() { - DateService dateService = injector.getInstance(DateService.class); - InputStream is = getClass().getResourceAsStream("/cancel_bundle_task.xml"); - BundleTask expected = new BundleTask(defaultRegion, "bun-cla322b9", null, "i-12345678", 20, dateService - .iso8601DateParse("2008-10-07T11:41:50.000Z"), "canceling", "my-bucket", "my-new-image", dateService - .iso8601DateParse("2008-10-07T11:51:50.000Z")); - - BundleTaskHandler handler = injector.getInstance(BundleTaskHandler.class); - addDefaultRegionToHandler(handler); - BundleTask result = factory.create(handler).parse(is); - - assertEquals(result, expected); - } - - private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) { - handler.setContext(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/xml/CreateVolumeResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/CreateVolumeResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/CreateVolumeResponseHandlerTest.java deleted file mode 100644 index 346c3ba..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/CreateVolumeResponseHandlerTest.java +++ /dev/null @@ -1,60 +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.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.aws.domain.Region; -import org.jclouds.date.DateService; -import org.jclouds.ec2.domain.Attachment; -import org.jclouds.ec2.domain.Volume; -import org.jclouds.http.functions.ParseSax; -import org.testng.annotations.Test; - -import com.google.common.collect.Sets; - -/** - * Tests behavior of {@code CreateVolumeResponseHandler} - * - * @author Adrian Cole - */ -//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "CreateVolumeResponseHandlerTest") -public class CreateVolumeResponseHandlerTest extends BaseEC2HandlerTest { - - public void testApplyInputStream() { - DateService dateService = injector.getInstance(DateService.class); - InputStream is = getClass().getResourceAsStream("/created_volume.xml"); - - Volume expected = new Volume(Region.US_EAST_1, "vol-2a21e543", 1, null, - "us-east-1a", Volume.Status.CREATING, dateService - .iso8601DateParse("2009-12-28T05:42:53.000Z"), Sets - .<Attachment> newLinkedHashSet()); - - CreateVolumeResponseHandler handler = injector.getInstance(CreateVolumeResponseHandler.class); - addDefaultRegionToHandler(handler); - Volume result = factory.create(handler).parse(is); - - assertEquals(result, expected); - } - - private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) { - handler.setContext(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/xml/DescribeAddressesResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandlerTest.java deleted file mode 100644 index 7c40ec5..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandlerTest.java +++ /dev/null @@ -1,57 +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.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.UnknownHostException; -import java.util.Set; - -import org.jclouds.ec2.domain.PublicIpInstanceIdPair; -import org.jclouds.http.functions.ParseSax; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; - -/** - * Tests behavior of {@code DescribeAddressesResponseHandler} - * - * @author Adrian Cole - */ -//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "DescribeAddressesResponseHandlerTest") -public class DescribeAddressesResponseHandlerTest extends BaseEC2HandlerTest { - public void testApplyInputStream() throws UnknownHostException { - - InputStream is = getClass().getResourceAsStream("/describe_addresses.xml"); - - DescribeAddressesResponseHandler handler = injector - .getInstance(DescribeAddressesResponseHandler.class); - addDefaultRegionToHandler(handler); - - Set<PublicIpInstanceIdPair> result = factory.create(handler).parse(is); - - assertEquals(result, ImmutableList.of(new PublicIpInstanceIdPair(defaultRegion, - "67.202.55.255", "i-f15ebb98"), new PublicIpInstanceIdPair(defaultRegion, - "67.202.55.233", null))); - } - - private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) { - handler.setContext(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/xml/DescribeAvailabilityZonesResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandlerTest.java deleted file mode 100644 index a58e1c9..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandlerTest.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.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.util.Set; - -import javax.inject.Singleton; - -import org.jclouds.ec2.domain.AvailabilityZoneInfo; -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.config.SaxParserModule; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Guice; -import com.google.inject.Provides; - -/** - * Tests behavior of {@code DescribeAvailabilityZonesResponseHandler} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "DescribeAvailabilityZonesResponseHandlerTest") -public class DescribeAvailabilityZonesResponseHandlerTest extends BaseHandlerTest { - - @BeforeTest - protected void setUpInjector() { - injector = Guice.createInjector(new SaxParserModule() { - - @Singleton - @Provides - @org.jclouds.location.Region - Supplier<String> provideDefaultRegion() { - return Suppliers.ofInstance("SHOULDNTSEETHISASXMLHASREGIONDATA"); - } - - }); - factory = injector.getInstance(ParseSax.Factory.class); - assert factory != null; - } - - public void testApplyInputStream() { - - InputStream is = getClass().getResourceAsStream("/availabilityZones.xml"); - - Set<AvailabilityZoneInfo> expected = ImmutableSet.<AvailabilityZoneInfo> of( - - new AvailabilityZoneInfo("us-east-1a", "available", "us-east-1", ImmutableSet.<String> of()), - new AvailabilityZoneInfo("us-east-1b", "available", "us-east-1", ImmutableSet - .<String> of()), - - new AvailabilityZoneInfo("us-east-1c", "available", "us-east-1", ImmutableSet - .<String> of("our service is awesome")), - - new AvailabilityZoneInfo("us-east-1d", "downlikeaclown", "us-east-1", ImmutableSet - .<String> of())); - Set<AvailabilityZoneInfo> result = factory.create( - injector.getInstance(DescribeAvailabilityZonesResponseHandler.class)).parse(is); - - assertEquals(result, expected); - } - -} 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/xml/DescribeBundleTasksResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandlerTest.java deleted file mode 100644 index 07c9a4d..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandlerTest.java +++ /dev/null @@ -1,56 +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.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.date.DateService; -import org.jclouds.ec2.domain.BundleTask; -import org.jclouds.http.functions.ParseSax; -import org.testng.annotations.Test; - -import com.google.common.collect.Iterables; - -/** - * Tests behavior of {@code DescribeBundleTasksResponseHandler} - * - * @author Adrian Cole - */ -//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "DescribeBundleTasksResponseHandlerTest") -public class DescribeBundleTasksResponseHandlerTest extends BaseEC2HandlerTest { - public void testApplyInputStream() { - DateService dateService = injector.getInstance(DateService.class); - InputStream is = getClass().getResourceAsStream("/describe_bundle_tasks.xml"); - - BundleTask expected = new BundleTask(defaultRegion, "bun-c1a540a8", null, "i-12345678", 20, dateService - .iso8601DateParse("2008-10-07T11:41:50.000Z"), "canceling", "my-bucket", "winami", dateService - .iso8601DateParse("2008-10-07T11:51:50.000Z")); - - DescribeBundleTasksResponseHandler handler = injector.getInstance(DescribeBundleTasksResponseHandler.class); - addDefaultRegionToHandler(handler); - BundleTask result = Iterables.getOnlyElement(factory.create(handler).parse(is)); - - assertEquals(result, expected); - } - - private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) { - handler.setContext(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/xml/DescribeImagesResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeImagesResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeImagesResponseHandlerTest.java deleted file mode 100644 index f2b0894..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeImagesResponseHandlerTest.java +++ /dev/null @@ -1,151 +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.xml; - -import static com.google.common.collect.Iterables.get; -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.util.Set; - -import org.jclouds.ec2.compute.functions.EC2ImageParserTest; -import org.jclouds.ec2.domain.Hypervisor; -import org.jclouds.ec2.domain.Image; -import org.jclouds.ec2.domain.RootDeviceType; -import org.jclouds.ec2.domain.VirtualizationType; -import org.jclouds.ec2.domain.Image.Architecture; -import org.jclouds.ec2.domain.Image.EbsBlockDevice; -import org.jclouds.ec2.domain.Image.ImageState; -import org.jclouds.ec2.domain.Image.ImageType; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.location.Region; -import org.testng.annotations.Test; - -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.TypeLiteral; - -/** - * Tests behavior of {@code DescribeImagesResponseHandler} - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "DescribeImagesResponseHandlerTest") -public class DescribeImagesResponseHandlerTest { - - public void testUNIX() { - Set<Image> contents = ImmutableSet.of(new Image("us-east-1", Architecture.I386, null, null, "ami-be3adfd7", - "ec2-public-images/fedora-8-i386-base-v1.04.manifest.xml", "206029621532", ImageState.AVAILABLE, "available", - ImageType.MACHINE, false, Sets.<String> newHashSet("9961934F"), "aki-4438dd2d", null, "ari-4538dd2c", - RootDeviceType.INSTANCE_STORE, null, ImmutableMap.<String, EbsBlockDevice> of(), - ImmutableMap.<String, String> of(), VirtualizationType.PARAVIRTUAL, Hypervisor.XEN)); - - Set<Image> result = parseImages("/describe_images.xml"); - - assertEquals(result.toString(), contents.toString()); - assertEquals(get(result, 0).getImageState(), ImageState.AVAILABLE); - assertEquals(get(result, 0).getRawState(), "available"); - } - - public void testWindows() { - Set<Image> contents = ImmutableSet.of(new Image("us-east-1", Architecture.X86_64, null, null, "ami-02eb086b", - "aws-solutions-amis/SqlSvrStd2003r2-x86_64-Win_SFWBasic5.1-v1.0.manifest.xml", "771350841976", - ImageState.AVAILABLE, "available", ImageType.MACHINE, true, Sets.<String> newHashSet("5771E9A6"), null, "windows", - null, RootDeviceType.INSTANCE_STORE, null, ImmutableMap.<String, EbsBlockDevice> of(), - ImmutableMap.<String, String> of(), VirtualizationType.PARAVIRTUAL, Hypervisor.XEN)); - - - Set<Image> result = parseImages("/describe_images_windows.xml"); - - assertEquals(result.toString(), contents.toString()); - assertEquals(get(result, 0).getImageState(), ImageState.AVAILABLE); - assertEquals(get(result, 0).getRawState(), "available"); - } - - public void testEBS() { - Set<Image> contents = ImmutableSet.of(new Image("us-east-1", Architecture.I386, "websrv_2009-12-10", - "Web Server AMI", "ami-246f8d4d", "706093390852/websrv_2009-12-10", "706093390852", - ImageState.AVAILABLE, "available", ImageType.MACHINE, true, Sets.<String> newHashSet(), null, "windows", null, - RootDeviceType.EBS, "/dev/sda1", ImmutableMap.<String, EbsBlockDevice> of("/dev/sda1", - new EbsBlockDevice("snap-d01272b9", 30, true), "xvdf", new EbsBlockDevice("snap-d31272ba", 250, - false)), ImmutableMap.<String, String> of(), VirtualizationType.HVM, Hypervisor.XEN)); - - Set<Image> result = parseImages("/describe_images_ebs.xml"); - - assertEquals(result.toString(), contents.toString()); - assertEquals(get(result, 0).getImageState(), ImageState.AVAILABLE); - assertEquals(get(result, 0).getRawState(), "available"); - } - - public void testTags() { - Set<Image> contents = ImmutableSet.of(new Image("us-east-1", Architecture.I386, null, null, "ami-be3adfd7", - "ec2-public-images/fedora-8-i386-base-v1.04.manifest.xml", "206029621532", ImageState.AVAILABLE, "available", - ImageType.MACHINE, false, Sets.<String> newHashSet("9961934F"), "aki-4438dd2d", null, "ari-4538dd2c", - RootDeviceType.INSTANCE_STORE, null, ImmutableMap.<String, EbsBlockDevice> of(), - ImmutableMap.<String, String> of("Name", "Some machine name", "Second", "Second value"), - VirtualizationType.PARAVIRTUAL, Hypervisor.XEN)); - - Set<Image> result = parseImages("/describe_images_tags.xml"); - - assertEquals(result.toString(), contents.toString()); - assertEquals(get(result, 0).getImageState(), ImageState.AVAILABLE); - assertEquals(get(result, 0).getRawState(), "available"); - assertEquals(get(result, 0).getTags().get("Name"), "Some machine name"); - assertEquals(get(result, 0).getTags().get("Second"), "Second value"); - } - - public void testDiabloWithIncorrectDisplayNameField() { - Set<Image> contents = ImmutableSet.of(new Image("us-east-1", Architecture.X86_64, "CentOS 6.2 Server 64-bit 20120125", "", "ami-0000054e", - "local (CentOS 6.2 Server 64-bit 20120125)", "", ImageState.AVAILABLE, "available", - ImageType.MACHINE, true, Sets.<String> newHashSet(), "aki-0000054c", null, "ari-0000054d", - RootDeviceType.INSTANCE_STORE, "/dev/sda1", ImmutableMap.<String, EbsBlockDevice> of(), - ImmutableMap.<String, String> of(), VirtualizationType.PARAVIRTUAL, Hypervisor.XEN)); - - Set<Image> result = parseImages("/describe_images_nova.xml"); - - assertEquals(result.toString(), contents.toString()); - assertEquals(get(result, 0).getImageState(), ImageState.AVAILABLE); - assertEquals(get(result, 0).getRawState(), "available"); - } - - static ParseSax<Set<Image>> createParser() { - Injector injector = Guice.createInjector(new SaxParserModule(), new AbstractModule() { - - @Override - protected void configure() { - bind(new TypeLiteral<Supplier<String>>() { - }).annotatedWith(Region.class).toInstance(Suppliers.ofInstance("us-east-1")); - } - - }); - ParseSax<Set<Image>> parser = injector.getInstance(ParseSax.Factory.class).create( - injector.getInstance(DescribeImagesResponseHandler.class)); - return parser; - } - - public static Set<Image> parseImages(String resource) { - InputStream is = EC2ImageParserTest.class.getResourceAsStream(resource); - return createParser().parse(is); - } -} 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/xml/DescribeInstanceAttributeTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeInstanceAttributeTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeInstanceAttributeTest.java deleted file mode 100644 index 43b4ba3..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeInstanceAttributeTest.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.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.ec2.domain.InstanceType; -import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code DescribeInstanceAttribute} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "DescribeInstanceAttributeTest") -public class DescribeInstanceAttributeTest extends BaseHandlerTest { - - public void testInstanceInitiatedShutdownBehaviorHandler() { - InputStream is = getClass().getResourceAsStream("/instanceInitiatedShutdownBehavior.xml"); - - InstanceInitiatedShutdownBehaviorHandler handler = injector - .getInstance(InstanceInitiatedShutdownBehaviorHandler.class); - InstanceInitiatedShutdownBehavior result = factory.create(handler).parse(is); - - assertEquals(result, InstanceInitiatedShutdownBehavior.STOP); - } - - public void testInstanceTypeHandler() { - InputStream is = getClass().getResourceAsStream("/instanceType.xml"); - - InstanceTypeHandler handler = injector.getInstance(InstanceTypeHandler.class); - String result = factory.create(handler).parse(is); - - assertEquals(result, InstanceType.M1_SMALL); - } - - public void testBooleanValueHandler() { - InputStream is = getClass().getResourceAsStream("/disableApiTermination.xml"); - - BooleanValueHandler handler = injector.getInstance(BooleanValueHandler.class); - Boolean result = factory.create(handler).parse(is); - - assert !result; - } - - public void testStringValueHandler() { - InputStream is = getClass().getResourceAsStream("/ramdisk.xml"); - - StringValueHandler handler = injector.getInstance(StringValueHandler.class); - String result = factory.create(handler).parse(is); - - assertEquals(result, "ari-a51cf9cc"); - } - - public void testUnencodeStringValueHandler() { - InputStream is = getClass().getResourceAsStream("/userData.xml"); - UnencodeStringValueHandler handler = injector.getInstance(UnencodeStringValueHandler.class); - String result = factory.create(handler).parse(is); - assertEquals(result, "#!/bin/bash\n"); - } -} 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/xml/DescribeInstancesResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandlerTest.java deleted file mode 100644 index f1ac58b..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandlerTest.java +++ /dev/null @@ -1,173 +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.xml; - -import static com.google.common.collect.Iterables.get; -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.UnknownHostException; -import java.util.Set; - -import org.jclouds.date.DateService; -import org.jclouds.ec2.domain.Attachment; -import org.jclouds.ec2.domain.BlockDevice; -import org.jclouds.ec2.domain.InstanceState; -import org.jclouds.ec2.domain.InstanceType; -import org.jclouds.ec2.domain.Reservation; -import org.jclouds.ec2.domain.RootDeviceType; -import org.jclouds.ec2.domain.RunningInstance; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.location.Region; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.TypeLiteral; - -/** - * Tests behavior of {@code DescribeInstancesResponseHandler} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "DescribeInstancesResponseHandlerTest") -public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest { - - private DateService dateService; - - @BeforeTest - @Override - protected void setUpInjector() { - super.setUpInjector(); - dateService = injector.getInstance(DateService.class); - assert dateService != null; - } - - public void testWhenRunning() throws UnknownHostException { - - Set<Reservation<RunningInstance>> contents = ImmutableSet.of(new Reservation<RunningInstance>(defaultRegion, - ImmutableSet.of("adriancole.ec2ingress"), ImmutableSet.of(RunningInstance.builder().region( - defaultRegion).groupName("adriancole.ec2ingress").amiLaunchIndex("0").dnsName( - "ec2-174-129-81-68.compute-1.amazonaws.com").imageId("ami-82e4b5c7").instanceId("i-0799056f") - .instanceState(InstanceState.RUNNING).rawState("running").instanceType(InstanceType.M1_SMALL) - .ipAddress("174.129.81.68").kernelId("aki-a71cf9ce").keyName("adriancole.ec21").launchTime( - dateService.iso8601DateParse("2009-11-09T03:00:34.000Z")) - // MonitoringState.DISABLED, - .availabilityZone("us-east-1c").virtualizationType("paravirtual").privateDnsName( - "ip-10-243-42-70.ec2.internal").privateIpAddress("10.243.42.70").ramdiskId( - "ari-a51cf9cc").rootDeviceType(RootDeviceType.INSTANCE_STORE).build()), - "993194456877", null, "r-a3c508cb")); - - Set<Reservation<? extends RunningInstance>> result = parseRunningInstances("/describe_instances_running.xml"); - - assertEquals(result.toString(), contents.toString()); - assertEquals(get(get(result, 0), 0).getInstanceState(), InstanceState.RUNNING); - assertEquals(get(get(result, 0), 0).getRawState(), "running"); - - } - - public void testApplyInputStream() { - Set<Reservation<RunningInstance>> contents = ImmutableSet.of(new Reservation<RunningInstance>(defaultRegion, - ImmutableSet.of("default"), ImmutableSet.of(RunningInstance.builder().region(defaultRegion).groupName( - "default").amiLaunchIndex("23").dnsName("ec2-72-44-33-4.compute-1.amazonaws.com").imageId( - "ami-6ea54007").instanceId("i-28a64341").instanceState(InstanceState.RUNNING).rawState( - "running").instanceType(InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName( - "example-key-name").launchTime(dateService.iso8601DateParse("2007-08-07T11:54:42.000Z")) - // MonitoringState.DISABLED, - .availabilityZone("us-east-1b").virtualizationType("paravirtual").privateDnsName( - "10-251-50-132.ec2.internal")// product codes - // ImmutableSet.of("774F4FF8") - .tags(ImmutableMap.of("Name","ec2-o", "Empty","")) - .ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE).build(), - RunningInstance.builder().region(defaultRegion).groupName("default").amiLaunchIndex("23") - .dnsName("ec2-72-44-33-6.compute-1.amazonaws.com").imageId("ami-6ea54007").instanceId( - "i-28a64435").instanceState(InstanceState.RUNNING).rawState("running") - .instanceType(InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName( - "example-key-name").launchTime( - dateService.iso8601DateParse("2007-08-07T11:54:42.000Z")) - // MonitoringState.DISABLED, - .availabilityZone("us-east-1b").virtualizationType("paravirtual").privateDnsName( - "10-251-50-134.ec2.internal")// product codes - // ImmutableSet.of("774F4FF8") - .ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE).build()), - "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", null, "r-44a5402d")); - - Set<Reservation<? extends RunningInstance>> result = parseRunningInstances("/describe_instances.xml"); - - assertEquals(result.toString(), contents.toString()); - assertEquals(get(get(result, 0), 0).getInstanceState(), InstanceState.RUNNING); - assertEquals(get(get(result, 0), 0).getRawState(), "running"); - - } - - public void testEBS() throws UnknownHostException { - - Set<Reservation<RunningInstance>> contents = ImmutableSet.of(new Reservation<RunningInstance>(defaultRegion, - ImmutableSet.of("adriancole.ec2ebsingress"), ImmutableSet.of(RunningInstance.builder().region( - defaultRegion).groupName("adriancole.ec2ebsingress").amiLaunchIndex("0").dnsName( - "ec2-75-101-203-146.compute-1.amazonaws.com").imageId("ami-849875ed").instanceId("i-e564438d") - .instanceState(InstanceState.RUNNING).rawState("running").instanceType(InstanceType.M1_SMALL) - .ipAddress("75.101.203.146").kernelId("aki-a71cf9ce") - .keyName("adriancole.ec2ebs1") - .launchTime(dateService.iso8601DateParse("2009-12-30T04:06:23.000Z")) - // MonitoringState.DISABLED - .availabilityZone("us-east-1b") - // "placement" - .virtualizationType("hvm").privateDnsName("domU-12-31-39-09-CE-53.compute-1.internal") - .privateIpAddress("10.210.209.157").ramdiskId("ari-a51cf9cc") - .rootDeviceType(RootDeviceType.EBS).rootDeviceName("/dev/sda1").device( - "/dev/sda1", - new BlockDevice("vol-dc6ca8b5", Attachment.Status.ATTACHED, dateService - .iso8601DateParse("2009-12-30T04:06:29.000Z"), true)).build()), - "993194456877", null, "r-596dd731")); - - Set<Reservation<? extends RunningInstance>> result = parseRunningInstances("/describe_instances_ebs.xml"); - - assertEquals(result.toString(), contents.toString()); - assertEquals(get(get(result, 0), 0).getInstanceState(), InstanceState.RUNNING); - assertEquals(get(get(result, 0), 0).getRawState(), "running"); - } - - static ParseSax<Set<Reservation<? extends RunningInstance>>> createParser() { - Injector injector = Guice.createInjector(new SaxParserModule(), new AbstractModule() { - - @Override - protected void configure() { - bind(new TypeLiteral<Supplier<String>>() { - }).annotatedWith(Region.class).toInstance(Suppliers.ofInstance("us-east-1")); - } - - }); - ParseSax<Set<Reservation<? extends RunningInstance>>> parser = injector - .getInstance(ParseSax.Factory.class) - .create(injector.getInstance(DescribeInstancesResponseHandler.class)); - return parser; - } - - public static Set<Reservation<? extends RunningInstance>> parseRunningInstances(String resource) { - InputStream is = DescribeInstancesResponseHandlerTest.class.getResourceAsStream(resource); - return createParser().parse(is); - } -} 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/xml/DescribeKeyPairsResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeKeyPairsResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeKeyPairsResponseHandlerTest.java deleted file mode 100644 index b3644dd..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeKeyPairsResponseHandlerTest.java +++ /dev/null @@ -1,53 +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.xml; -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.util.Set; - -import org.jclouds.ec2.domain.KeyPair; -import org.jclouds.http.functions.ParseSax; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * Tests behavior of {@code DescribeKeyPairsResponseHandler} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "DescribeKeyPairsResponseHandlerTest") -public class DescribeKeyPairsResponseHandlerTest extends BaseEC2HandlerTest { - public void testApplyInputStream() { - - InputStream is = getClass().getResourceAsStream("/describe_keypairs.xml"); - - Set<KeyPair> expected = ImmutableSet.of(new KeyPair(defaultRegion, "gsg-keypair", - "1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f", null, null)); - - DescribeKeyPairsResponseHandler handler = injector.getInstance(DescribeKeyPairsResponseHandler.class); - addDefaultRegionToHandler(handler); - Set<KeyPair> result = factory.create(handler).parse(is); - assertEquals(result, expected); - } - - private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) { - handler.setContext(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/xml/DescribeRegionsResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandlerTest.java deleted file mode 100644 index 1e444e3..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandlerTest.java +++ /dev/null @@ -1,136 +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.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; -import java.util.Map; - -import org.jclouds.aws.domain.Region; -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.location.Provider; -import org.jclouds.util.Strings2; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.ImmutableMap; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.TypeLiteral; - -/** - * Tests behavior of {@code DescribeRegionsResponseHandler} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "DescribeRegionsResponseHandlerTest") -public class DescribeRegionsResponseHandlerTest extends BaseHandlerTest { - @BeforeTest - @Override - protected void setUpInjector() { - injector = Guice.createInjector(new SaxParserModule(), new AbstractModule() { - - @Override - protected void configure() { - bind(new TypeLiteral<Supplier<URI>>(){}).annotatedWith(Provider.class).toInstance( - Suppliers.ofInstance(URI.create("https://booya"))); - } - - }); - factory = injector.getInstance(ParseSax.Factory.class); - assert factory != null; - } - - public void testApplyInputStream() { - - InputStream is = getClass().getResourceAsStream( - "/regionEndpoints.xml"); - - Map<String, URI> expected = ImmutableMap - .<String, URI> of(Region.EU_WEST_1, URI - .create("https://ec2.eu-west-1.amazonaws.com"), - Region.US_EAST_1, URI - .create("https://ec2.us-east-1.amazonaws.com"), - Region.US_WEST_1, URI - .create("https://ec2.us-west-1.amazonaws.com")); - - Map<String, URI> result = factory.create( - injector.getInstance(DescribeRegionsResponseHandler.class)).parse( - is); - - assertEquals(result, expected); - } - - public void testEuc() { - - InputStream is = Strings2 - .toInputStream("<DescribeRegionsResponse xmlns=\"http://ec2.amazonaws.com/doc/2010-08-31/\"><requestId>6a3b36f9-9ff4-47cf-87e3-285b08fbe5e5</requestId><regionInfo><item><regionName>Eucalyptus</regionName><regionEndpoint>http://173.205.188.130:8773/services/Eucalyptus</regionEndpoint></item><item><regionName>Walrus</regionName><regionEndpoint>http://173.205.188.130:8773/services/Walrus</regionEndpoint></item></regionInfo></DescribeRegionsResponse>"); - - Map<String, URI> expected = ImmutableMap.<String, URI> of("Eucalyptus", - URI.create("http://173.205.188.130:8773/services/Eucalyptus")); - - Map<String, URI> result = factory.create( - injector.getInstance(DescribeRegionsResponseHandler.class)).parse( - is); - - assertEquals(result, expected); - } - - public void testEuc2() { - - InputStream is = Strings2 - .toInputStream("<?xml version=\"1.0\" ?><DescribeRegionsResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-11-30/\"><requestId>1LAQRTCLTLPS6CEIC627</requestId><regionInfo><item><regionUrl>http://10.255.255.1:8773/services/Cloud</regionUrl><regionName>nova</regionName></item></regionInfo></DescribeRegionsResponse>"); - - Map<String, URI> expected = ImmutableMap.<String, URI> of("nova", - URI.create("http://10.255.255.1:8773/services/Cloud")); - - Map<String, URI> result = factory.create( - injector.getInstance(DescribeRegionsResponseHandler.class)).parse( - is); - - assertEquals(result, expected); - } - - public void testUnsupportedAdditionalRegionDoesntBreak() { - - InputStream is = getClass().getResourceAsStream( - "/regionEndpoints-additional.xml"); - - Map<String, URI> expected = ImmutableMap - .<String, URI> of("jp-west-1", URI - .create("https://ec2.jp-west-1.amazonaws.com"), - Region.EU_WEST_1, URI - .create("https://ec2.eu-west-1.amazonaws.com"), - Region.US_EAST_1, URI - .create("https://ec2.us-east-1.amazonaws.com"), - Region.US_WEST_1, URI - .create("https://ec2.us-west-1.amazonaws.com")); - - Map<String, URI> result = factory.create( - injector.getInstance(DescribeRegionsResponseHandler.class)).parse( - is); - - assertEquals(result, expected); - } -} 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/xml/DescribeSecurityGroupsResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandlerTest.java deleted file mode 100644 index caabd1a..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandlerTest.java +++ /dev/null @@ -1,89 +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.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.util.Set; - -import org.jclouds.ec2.domain.SecurityGroup; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.net.domain.IpPermission; -import org.jclouds.net.domain.IpProtocol; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.LinkedHashMultimap; -import com.google.common.collect.Multimap; - -/** - * Tests behavior of {@code DescribeSecurityGroupsResponseHandler} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during -// surefire -@Test(groups = "unit", testName = "DescribeSecurityGroupsResponseHandlerTest") -public class DescribeSecurityGroupsResponseHandlerTest extends BaseEC2HandlerTest { - public void testApplyInputStream() { - - InputStream is = getClass().getResourceAsStream("/describe_securitygroups.xml"); - - Set<SecurityGroup> expected = ImmutableSet.of( - new SecurityGroup(defaultRegion, "sg-3c6ef654", "WebServers", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Web Servers", - ImmutableSet.of(new IpPermission(IpProtocol.TCP, 80, 80, ImmutableMultimap.<String, String> of(), - ImmutableSet.<String> of(), ImmutableSet.of("0.0.0.0/0")))), - new SecurityGroup(defaultRegion, "sg-867309ab", "RangedPortsBySource", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Group A", - ImmutableSet.of(new IpPermission(IpProtocol.TCP, 6000, 7000, ImmutableMultimap - .<String, String> of(), ImmutableSet.<String> of(), ImmutableSet.<String> of())))); - - DescribeSecurityGroupsResponseHandler handler = injector.getInstance(DescribeSecurityGroupsResponseHandler.class); - addDefaultRegionToHandler(handler); - Set<SecurityGroup> result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - } - - // Response from OpenStack 1.1 EC2 API - public void testApplyInputStreamWithEmptyFields() { - - InputStream is = getClass().getResourceAsStream("/describe_securitygroups_empty.xml"); - - Multimap<String, String> userIdGroupPairs = LinkedHashMultimap.create(); - userIdGroupPairs.put("UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "jclouds#cluster#world"); - - Set<SecurityGroup> expected = ImmutableSet.of( - new SecurityGroup(defaultRegion, "sg-3c6ef654", "jclouds#cluster#world", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Cluster", - ImmutableSet.of( - new IpPermission(IpProtocol.TCP, 22, 22, ImmutableMultimap.<String, String> of(), - ImmutableSet.<String> of(), ImmutableSet.of("0.0.0.0/0")), - new IpPermission(IpProtocol.ALL, -1, -1, userIdGroupPairs, - ImmutableSet.<String> of(), ImmutableSet.<String> of())))); - - DescribeSecurityGroupsResponseHandler handler = injector.getInstance(DescribeSecurityGroupsResponseHandler.class); - addDefaultRegionToHandler(handler); - Set<SecurityGroup> result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - } - - private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) { - handler.setContext(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/xml/DescribeSnapshotsResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandlerTest.java deleted file mode 100644 index 9f6fbfb..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandlerTest.java +++ /dev/null @@ -1,59 +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.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.util.Set; - -import org.jclouds.date.DateService; -import org.jclouds.ec2.domain.Snapshot; -import org.jclouds.http.functions.ParseSax; -import org.testng.annotations.Test; - -import com.google.common.collect.Sets; - -/** - * Tests behavior of {@code DescribeSnapshotsResponseHandler} - * - * @author Adrian Cole - */ -//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "DescribeSnapshotsResponseHandlerTest") -public class DescribeSnapshotsResponseHandlerTest extends BaseEC2HandlerTest { - public void testApplyInputStream() { - DateService dateService = injector.getInstance(DateService.class); - InputStream is = getClass().getResourceAsStream("/describe_snapshots.xml"); - - Set<Snapshot> expected = Sets.newLinkedHashSet(); - expected.add(new Snapshot(defaultRegion, "snap-78a54011", "vol-4d826724", 10, - Snapshot.Status.PENDING, dateService.iso8601DateParse("2008-05-07T12:51:50.000Z"), - 80, "218213537122", "Daily Backup", null)); - - DescribeSnapshotsResponseHandler handler = injector - .getInstance(DescribeSnapshotsResponseHandler.class); - addDefaultRegionToHandler(handler); - Set<Snapshot> result = factory.create(handler).parse(is); - - assertEquals(result, expected); - } - - private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) { - handler.setContext(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/xml/DescribeVolumesResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandlerTest.java deleted file mode 100644 index ae286c9..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandlerTest.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.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.util.Set; - -import org.jclouds.date.DateService; -import org.jclouds.ec2.domain.Attachment; -import org.jclouds.ec2.domain.Volume; -import org.jclouds.http.functions.ParseSax; -import org.testng.annotations.Test; - -import com.google.common.collect.Sets; - -/** - * Tests behavior of {@code DescribeVolumesResponseHandler} - * - * @author Adrian Cole - */ -//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "DescribeVolumesResponseHandlerTest") -public class DescribeVolumesResponseHandlerTest extends BaseEC2HandlerTest { - - public void testApplyInputStream() { - DateService dateService = injector.getInstance(DateService.class); - InputStream is = getClass().getResourceAsStream("/describe_volumes.xml"); - - Set<Volume> expected = Sets.newLinkedHashSet(); - expected.add(new Volume(defaultRegion, "vol-2a21e543", 1, null, "us-east-1a", - Volume.Status.AVAILABLE, dateService.iso8601DateParse("2009-12-28T05:42:53.000Z"), - Sets.<Attachment> newLinkedHashSet())); - expected.add(new Volume(defaultRegion, "vol-4282672b", 800, "snap-536d1b3a", - "us-east-1a", Volume.Status.IN_USE, dateService - .iso8601DateParse("2008-05-07T11:51:50.000Z"), Sets - .<Attachment> newHashSet(new Attachment(defaultRegion, "vol-4282672b", "i-6058a509", - "/dev/sdh", Attachment.Status.ATTACHED, dateService - .iso8601DateParse("2008-05-07T12:51:50.000Z"))))); - - DescribeVolumesResponseHandler handler = injector - .getInstance(DescribeVolumesResponseHandler.class); - addDefaultRegionToHandler(handler); - Set<Volume> result = factory.create(handler).parse(is); - - assertEquals(result, expected); - } - - private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) { - handler.setContext(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/xml/GetConsoleOutputResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandlerTest.java deleted file mode 100644 index 1598192..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandlerTest.java +++ /dev/null @@ -1,55 +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.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code GetConsoleOutputResponseHandler} - * - * @author Andrew Kennedy - */ -//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "GetConsoleOutputResponseHandlerTest") -public class GetConsoleOutputResponseHandlerTest extends BaseHandlerTest { - public void testApplyInputStream() { - - InputStream is = getClass().getResourceAsStream( - "/get_console_output_response.xml"); - - String result = factory.create( - injector.getInstance(GetConsoleOutputResponseHandler.class)).parse(is); - - String expected = "Linux version 2.6.16-xenU ([email protected]) (gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)) #1 SMP Thu Oct 26 08:41:26 SAST 2006\n" + - "BIOS-provided physical RAM map:\n" + - "Xen: 0000000000000000 - 000000006a400000 (usable)\n" + - "980MB HIGHMEM available.\n" + - "727MB LOWMEM available.\n" + - "NX (Execute Disable) protection: active\n" + - "IRQ lockup detection disabled\n" + - "Built 1 zonelists\n" + - "Kernel command line: root=/dev/sda1 ro 4\n" + - "Enabling fast FPU save and restore... done.\n"; - - assertEquals(result, expected); - } -} 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/xml/InstanceStateChangeHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/InstanceStateChangeHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/InstanceStateChangeHandlerTest.java deleted file mode 100644 index 929d5a5..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/InstanceStateChangeHandlerTest.java +++ /dev/null @@ -1,93 +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.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.util.Set; - -import org.jclouds.date.DateService; -import org.jclouds.ec2.domain.InstanceState; -import org.jclouds.ec2.domain.InstanceStateChange; -import org.jclouds.http.functions.ParseSax; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * Tests behavior of {@code InstanceStateChangeHandler} - * - * @author Adrian Cole - */ -//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "InstanceStateChangeHandlerTest") -public class InstanceStateChangeHandlerTest extends BaseEC2HandlerTest { - - private DateService dateService; - - @BeforeTest - @Override - protected void setUpInjector() { - super.setUpInjector(); - dateService = injector.getInstance(DateService.class); - assert dateService != null; - } - - public void testTerminate() { - - InputStream is = getClass().getResourceAsStream("/terminate_instances.xml"); - - Set<InstanceStateChange> expected = ImmutableSet.of(new InstanceStateChange(defaultRegion, - "i-3ea74257", InstanceState.SHUTTING_DOWN, InstanceState.RUNNING)); - - InstanceStateChangeHandler handler = injector.getInstance(InstanceStateChangeHandler.class); - addDefaultRegionToHandler(handler); - Set<InstanceStateChange> result = factory.create(handler).parse(is); - assertEquals(result, expected); - } - - public void testStart() { - - InputStream is = getClass().getResourceAsStream("/start_instances.xml"); - - Set<InstanceStateChange> expected = ImmutableSet.of(new InstanceStateChange(defaultRegion, - "i-10a64379", InstanceState.PENDING, InstanceState.STOPPED)); - InstanceStateChangeHandler handler = injector.getInstance(InstanceStateChangeHandler.class); - addDefaultRegionToHandler(handler); - Set<InstanceStateChange> result = factory.create(handler).parse(is); - assertEquals(result, expected); - } - - public void testStop() { - - InputStream is = getClass().getResourceAsStream("/stop_instances.xml"); - - Set<InstanceStateChange> expected = ImmutableSet.of(new InstanceStateChange(defaultRegion, - "i-10a64379", InstanceState.STOPPING, InstanceState.RUNNING)); - - InstanceStateChangeHandler handler = injector.getInstance(InstanceStateChangeHandler.class); - addDefaultRegionToHandler(handler); - Set<InstanceStateChange> result = factory.create(handler).parse(is); - assertEquals(result, expected); - } - - private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) { - handler.setContext(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/xml/KeyPairResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/KeyPairResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/KeyPairResponseHandlerTest.java deleted file mode 100644 index 1ee4323..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/KeyPairResponseHandlerTest.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.xml; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.io.InputStream; - -import org.jclouds.ec2.domain.KeyPair; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.ssh.SshKeys; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code KeyPairResponseHandler} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "KeyPairResponseHandlerTest") -public class KeyPairResponseHandlerTest extends BaseEC2HandlerTest { - public void testApplyInputStream() throws IOException { - - InputStream is = getClass().getResourceAsStream("/create_keypair.xml"); - - KeyPair expected = KeyPair.builder().region(defaultRegion).keyName("jclouds#test#0").sha1OfPrivateKey( - "13:36:74:b9:56:bb:07:96:c0:19:ab:00:7f:9f:06:d2:16:a0:45:32").keyMaterial( - "-----BEGIN RSA PRIVATE KEY-----\n" - + "MIIEowIBAAKCAQEA0CbFlhSdbMdad2ux2BVqk6Ut5fLKb0CdbqubGcEBfwsSz9Rp4Ile76P90MpV\n" - + "W1BGKL5V4MO+flG6dZnRWPVmgrNVyDTmEsALiMGjfEwbACEZ1A8C6mPa36wWO7MlxuyMjg8OczTB\n" - + "EXnHNDpxE5a6KowJtzFlmgjHk2Y+Q42UIqPx47lQUv5bdMDCnfNNomSzTVRjOZLUkDja+ybCKdux\n" - + "gqTsuInhuBRMx+wxff8Z43ECdJV6UPoXK3der1dlZunxGCFkCeYq0kCX7FZ7PV35X744jqhD8P+7\n" - + "y5prO4W+M3DWgChUx0OlbDbSHtDVlcfdbj/+4AKYKU6rQOqh+4DPDQIDAQABAoIBAHjQuEiXKJSV\n" - + "1U2RZcVtENInws9AL/2I/Jfa5Qh6vTqXG9EjklywfzkK72x7tDVvD3ngmAoAs5WwLFDL+fXvYhOk\n" - + "sbql8ZCahVdYRWME7XsSu2IZYHDZipXe1XzLS7b9X8uos5Ns4E8bZuNKtI1RJDdD1vPMqRNR2z0T\n" - + "0Dn3eC7t+t+t7PWaK5AXu2ot7DoOeG1QhqJbwd5pMkIn2ydBILytgmDk/2P3EtJGePIJIeQBicmw\n" - + "Z0KrJFa/K2cC8AtmMJUoZMo+mh1yemDbDLCZW30PjFHbZtcszS2cydAgq/HDFkZynvZG0zhbx/To\n" - + "jzcNza1AyypYwOwb2/9/ulXZp0UCgYEA+QFgWDfYLH2zwjU5b6e0UbIyd/X/yRZ+L8lOEBd0Bbu8\n" - + "qO3txaDbwi7o2mG7pJENHJ3u62CHjgTGDNW9V9Q8eNoGtj3uHvMvi7FdDEK8B6izdZyR7hmZmQ/5\n" - + "MIldelyiGZlz1KBSoy4FsCpA7hV7cI6H6x+Im24NxG90/wd/EgMCgYEA1f+cUyUisIO3yKOCf0hQ\n" - + "aL289q2//F2cbvBxtki6I8JzTg1H3oTO2WVrXQeCA3a/yiuRUatgGH4mxrpCF6byVJyqrEWAj4kU\n" - + "uTbhMgIYhLGoaF1e+vMirCRXUXox0i5X976ASzHn64V9JSd1B+UbKfpcFTYYnChmrRDzmhKN1a8C\n" - + "gYBTvIHAyO7ab18/BRUOllAOVSWhr8lXv0eqHEEzKh/rOaoFCRY3qpOcZpgJsGogumK1Z+sLnoeX\n" - + "W8WaVVp6KbY4UeGF8aedItyvVnLbB6ohzTqkZ4Wvk05S6cs75kXYO0SL5U3NiCiiFXz2NA9nwTOk\n" - + "s1nD2PPgiQ76Kx0mEkhKLwKBgFhHEJqv+AZu37Kx2NRe5WS/2KK9/DPD/hM5tv7mM3sq7Nvm2J3v\n" - + "lVDS6J5AyZ5aLzXcER9qncKcz6wtC7SsFs1Wr4VPSoBroRPikrVJbgnXK8yZr+O/xq7Scv7WdJTq\n" - + "rzkw6cWbObvLnltkUn/GQBVqBPBvF2nbtLdyBbuqKb5bAoGBAI1+aoJnvXEXxT4UHrMkQcY0eXRz\n" - + "3UdbzJmtjMW9CR6l9s11mV6PcZP4qnODp3nd6a+lPeL3wVYQ47DsTJ/Bx5dI17zA5mU57n6mV0a3\n" - + "DbSoPKSdaKTQdo2THnVE9P9sPKZWueAcsE4Yw/qcTjoxrtUnAH/AXN250v0tkKIOvMhu\n" - + "-----END RSA PRIVATE KEY-----").build(); - - KeyPairResponseHandler handler = injector.getInstance(KeyPairResponseHandler.class); - addDefaultRegionToHandler(handler); - KeyPair result = factory.create(handler).parse(is); - - assertEquals(result, expected); - - assert SshKeys.privateKeyHasSha1(result.getKeyMaterial(), result.getSha1OfPrivateKey()); - assert SshKeys.privateKeyHasFingerprint(result.getKeyMaterial(), result.getFingerprint()); - - } - - private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) { - handler.setContext(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/xml/PermissionHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/PermissionHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/PermissionHandlerTest.java deleted file mode 100644 index e031c3d..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/PermissionHandlerTest.java +++ /dev/null @@ -1,48 +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.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.ec2.domain.Permission; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.Sets; - -/** - * Tests behavior of {@code PermissionHandler} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "PermissionHandlerTest") -public class PermissionHandlerTest extends BaseHandlerTest { - public void testApplyInputStream() { - - InputStream is = getClass().getResourceAsStream( - "/describe_image_attribute_launchPermission.xml"); - - Permission expected = new Permission(Sets.newHashSet("495219933132"), Sets.newHashSet("all")); - - Permission result = factory.create(injector.getInstance(PermissionHandler.class)).parse(is); - - assertEquals(result, expected); - } -} 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/xml/RunInstancesResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/RunInstancesResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/RunInstancesResponseHandlerTest.java deleted file mode 100644 index 1d22a66..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/RunInstancesResponseHandlerTest.java +++ /dev/null @@ -1,110 +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.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.date.DateService; -import org.jclouds.ec2.domain.InstanceState; -import org.jclouds.ec2.domain.InstanceType; -import org.jclouds.ec2.domain.Reservation; -import org.jclouds.ec2.domain.RootDeviceType; -import org.jclouds.ec2.domain.RunningInstance; -import org.jclouds.http.functions.ParseSax; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * Tests behavior of {@code RunInstancesResponseHandler} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "RunInstancesResponseHandlerTest") -public class RunInstancesResponseHandlerTest extends BaseEC2HandlerTest { - - private DateService dateService; - - @BeforeTest - @Override - protected void setUpInjector() { - super.setUpInjector(); - dateService = injector.getInstance(DateService.class); - assert dateService != null; - } - - public void testEC2() { - - InputStream is = getClass().getResourceAsStream("/run_instances.xml"); - - Reservation<? extends RunningInstance> expected = new Reservation<RunningInstance>(defaultRegion, ImmutableSet - .of("default"), ImmutableSet.of( - - RunningInstance.builder().region(defaultRegion).groupName("default").amiLaunchIndex("0") - .imageId("ami-60a54009").instanceId("i-2ba64342").instanceState(InstanceState.PENDING).rawState( - "pending").instanceType(InstanceType.M1_SMALL).keyName("example-key-name").launchTime( - dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))// MonitoringState.ENABLED, - .availabilityZone("us-east-1b").build(), - - RunningInstance.builder().region(defaultRegion).groupName("default").amiLaunchIndex("1") - .imageId("ami-60a54009").instanceId("i-2bc64242").instanceState(InstanceState.PENDING).rawState( - "pending").instanceType(InstanceType.M1_SMALL).keyName("example-key-name").launchTime( - dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))// MonitoringState.ENABLED, - .availabilityZone("us-east-1b").build(), - - RunningInstance.builder().region(defaultRegion).groupName("default").amiLaunchIndex("2") - .imageId("ami-60a54009").instanceId("i-2be64332").instanceState(InstanceState.PENDING).rawState( - "pending").instanceType(InstanceType.M1_SMALL).keyName("example-key-name").launchTime( - dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))// MonitoringState.ENABLED, - .availabilityZone("us-east-1b").build()) - - , "AIDADH4IGTRXXKCD", null, "r-47a5402e"); - - RunInstancesResponseHandler handler = injector.getInstance(RunInstancesResponseHandler.class); - addDefaultRegionToHandler(handler); - Reservation<? extends RunningInstance> result = factory.create(handler).parse(is); - assertEquals(result.toString(), expected.toString()); - } - - public void testCloudBridge() { - - InputStream is = getClass().getResourceAsStream("/run_instances_cloudbridge.xml"); - - Reservation<? extends RunningInstance> expected = new Reservation<RunningInstance>(defaultRegion, ImmutableSet - .of("jclouds#greenqloud-computeblock"), ImmutableSet.of( - - RunningInstance.builder().region(defaultRegion).groupName("jclouds#greenqloud-computeblock").amiLaunchIndex("0") - .imageId("qmi-9ac92558").instanceId("i-01b0dac3").instanceState(InstanceState.PENDING).rawState( - "pending").instanceType(InstanceType.M1_SMALL).keyName("jclouds#greenqloud-computeblock#35") - .launchTime(dateService.iso8601DateParse("2012-06-15T19:06:35.000+00:00")) - .rootDeviceType(RootDeviceType.EBS).availabilityZone("is-1a").build()) - , "56eeacd9-c790-45c3-85f3-e4380b55e1d8<", null, "r-f847a6ca"); - - RunInstancesResponseHandler handler = injector.getInstance(RunInstancesResponseHandler.class); - addDefaultRegionToHandler(handler); - Reservation<? extends RunningInstance> result = factory.create(handler).parse(is); - assertEquals(result.toString(), expected.toString()); - } - - private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) { - handler.setContext(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/xml/SnapshotHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/SnapshotHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/SnapshotHandlerTest.java deleted file mode 100644 index 993bf87..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/SnapshotHandlerTest.java +++ /dev/null @@ -1,53 +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.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.date.DateService; -import org.jclouds.ec2.domain.Snapshot; -import org.jclouds.http.functions.ParseSax; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code SnapshotHandler} - * - * @author Adrian Cole - */ -//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "SnapshotHandlerTest") -public class SnapshotHandlerTest extends BaseEC2HandlerTest { - public void testApplyInputStream() { - DateService dateService = injector.getInstance(DateService.class); - InputStream is = getClass().getResourceAsStream("/created_snapshot.xml"); - - Snapshot expected = new Snapshot(defaultRegion, "snap-78a54011", "vol-4d826724", 10, - Snapshot.Status.PENDING, dateService.iso8601DateParse("2008-05-07T12:51:50.000Z"), - 60, "213457642086", "Daily Backup", null); - - SnapshotHandler handler = injector.getInstance(SnapshotHandler.class); - addDefaultRegionToHandler(handler); - Snapshot result = factory.create(handler).parse(is); - assertEquals(result, expected); - } - - private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) { - handler.setContext(request); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/allocate_address.xml ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/allocate_address.xml b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/allocate_address.xml deleted file mode 100644 index 25426c0..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/allocate_address.xml +++ /dev/null @@ -1,3 +0,0 @@ -<AllocateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/"> - <publicIp>67.202.55.255</publicIp> -</AllocateAddressResponse> \ No newline at end of file
