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/DescribeImagesOptionsTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DescribeImagesOptionsTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DescribeImagesOptionsTest.java deleted file mode 100644 index 7626c61..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DescribeImagesOptionsTest.java +++ /dev/null @@ -1,134 +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.DescribeImagesOptions.Builder.executableBy; -import static org.jclouds.ec2.options.DescribeImagesOptions.Builder.imageIds; -import static org.jclouds.ec2.options.DescribeImagesOptions.Builder.ownedBy; -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 DescribeImagesOptions and DescribeImagesOptions.Builder.* - * - * @author Adrian Cole - */ -public class DescribeImagesOptionsTest { - - @Test - public void testAssignability() { - assert HttpRequestOptions.class.isAssignableFrom(DescribeImagesOptions.class); - assert !String.class.isAssignableFrom(DescribeImagesOptions.class); - } - - @Test - public void testExecutableBy() { - DescribeImagesOptions options = new DescribeImagesOptions(); - options.executableBy("test"); - assertEquals(options.buildFormParameters().get("ExecutableBy"), - ImmutableList.of("test")); - } - - @Test - public void testNullExecutableBy() { - DescribeImagesOptions options = new DescribeImagesOptions(); - assertEquals(options.buildFormParameters().get("ExecutableBy"), ImmutableList.of()); - } - - @Test - public void testExecutableByStatic() { - DescribeImagesOptions options = executableBy("test"); - assertEquals(options.buildFormParameters().get("ExecutableBy"), - ImmutableList.of("test")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testExecutableByNPE() { - executableBy(null); - } - - @Test - public void testOwners() { - DescribeImagesOptions options = new DescribeImagesOptions(); - options.ownedBy("test"); - assertEquals(options.buildFormParameters().get("Owner.1"), ImmutableList.of("test")); - } - - @Test - public void testMultipleOwners() { - DescribeImagesOptions options = new DescribeImagesOptions(); - options.ownedBy("test", "trouble"); - assertEquals(options.buildFormParameters().get("Owner.1"), ImmutableList.of("test")); - assertEquals(options.buildFormParameters().get("Owner.2"), - ImmutableList.of("trouble")); - } - - @Test - public void testNullOwners() { - DescribeImagesOptions options = new DescribeImagesOptions(); - assertEquals(options.buildFormParameters().get("Owner.1"), ImmutableList.of()); - } - - @Test - public void testOwnersStatic() { - DescribeImagesOptions options = ownedBy("test"); - assertEquals(options.buildFormParameters().get("Owner.1"), ImmutableList.of("test")); - } - - public void testNoOwners() { - ownedBy(); - } - - @Test - public void testImageIds() { - DescribeImagesOptions options = new DescribeImagesOptions(); - options.imageIds("test"); - assertEquals(options.buildFormParameters().get("ImageId.1"), - ImmutableList.of("test")); - } - - @Test - public void testMultipleImageIds() { - DescribeImagesOptions options = new DescribeImagesOptions(); - options.imageIds("test", "trouble"); - assertEquals(options.buildFormParameters().get("ImageId.1"), - ImmutableList.of("test")); - assertEquals(options.buildFormParameters().get("ImageId.2"), - ImmutableList.of("trouble")); - } - - @Test - public void testNullImageIds() { - DescribeImagesOptions options = new DescribeImagesOptions(); - assertEquals(options.buildFormParameters().get("ImageId.1"), ImmutableList.of()); - } - - @Test - public void testImageIdsStatic() { - DescribeImagesOptions options = imageIds("test"); - assertEquals(options.buildFormParameters().get("ImageId.1"), - ImmutableList.of("test")); - } - - public void testNoImageIds() { - imageIds(); - } -}
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/DescribeSnapshotsOptionsTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DescribeSnapshotsOptionsTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DescribeSnapshotsOptionsTest.java deleted file mode 100644 index d4d4c00..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DescribeSnapshotsOptionsTest.java +++ /dev/null @@ -1,129 +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.DescribeSnapshotsOptions.Builder.ownedBy; -import static org.jclouds.ec2.options.DescribeSnapshotsOptions.Builder.restorableBy; -import static org.jclouds.ec2.options.DescribeSnapshotsOptions.Builder.snapshotIds; -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 DescribeSnapshotsOptions and DescribeSnapshotsOptions.Builder.* - * - * @author Adrian Cole - */ -public class DescribeSnapshotsOptionsTest { - - @Test - public void testAssignability() { - assert HttpRequestOptions.class.isAssignableFrom(DescribeSnapshotsOptions.class); - assert !String.class.isAssignableFrom(DescribeSnapshotsOptions.class); - } - - @Test - public void testRestorableBy() { - DescribeSnapshotsOptions options = new DescribeSnapshotsOptions(); - options.restorableBy("test"); - assertEquals(options.buildFormParameters().get("RestorableBy.1"), - ImmutableList.of("test")); - } - - @Test - public void testNullRestorableBy() { - DescribeSnapshotsOptions options = new DescribeSnapshotsOptions(); - assertEquals(options.buildFormParameters().get("RestorableBy.1"), ImmutableList.of()); - } - - @Test - public void testRestorableByStatic() { - DescribeSnapshotsOptions options = restorableBy("test"); - assertEquals(options.buildFormParameters().get("RestorableBy.1"), - ImmutableList.of("test")); - } - - @Test - public void testOwners() { - DescribeSnapshotsOptions options = new DescribeSnapshotsOptions(); - options.ownedBy("test"); - assertEquals(options.buildFormParameters().get("Owner.1"), ImmutableList.of("test")); - } - - @Test - public void testMultipleOwners() { - DescribeSnapshotsOptions options = new DescribeSnapshotsOptions(); - options.ownedBy("test", "trouble"); - assertEquals(options.buildFormParameters().get("Owner.1"), ImmutableList.of("test")); - assertEquals(options.buildFormParameters().get("Owner.2"), - ImmutableList.of("trouble")); - } - - @Test - public void testNullOwners() { - DescribeSnapshotsOptions options = new DescribeSnapshotsOptions(); - assertEquals(options.buildFormParameters().get("Owner.1"), ImmutableList.of()); - } - - @Test - public void testOwnersStatic() { - DescribeSnapshotsOptions options = ownedBy("test"); - assertEquals(options.buildFormParameters().get("Owner.1"), ImmutableList.of("test")); - } - - public void testNoOwners() { - ownedBy(); - } - - @Test - public void testSnapshotIds() { - DescribeSnapshotsOptions options = new DescribeSnapshotsOptions(); - options.snapshotIds("test"); - assertEquals(options.buildFormParameters().get("SnapshotId.1"), - ImmutableList.of("test")); - } - - @Test - public void testMultipleSnapshotIds() { - DescribeSnapshotsOptions options = new DescribeSnapshotsOptions(); - options.snapshotIds("test", "trouble"); - assertEquals(options.buildFormParameters().get("SnapshotId.1"), - ImmutableList.of("test")); - assertEquals(options.buildFormParameters().get("SnapshotId.2"), - ImmutableList.of("trouble")); - } - - @Test - public void testNullSnapshotIds() { - DescribeSnapshotsOptions options = new DescribeSnapshotsOptions(); - assertEquals(options.buildFormParameters().get("SnapshotId.1"), ImmutableList.of()); - } - - @Test - public void testSnapshotIdsStatic() { - DescribeSnapshotsOptions options = snapshotIds("test"); - assertEquals(options.buildFormParameters().get("SnapshotId.1"), - ImmutableList.of("test")); - } - - public void testNoSnapshotIds() { - snapshotIds(); - } -} 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/DetachVolumeOptionsTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DetachVolumeOptionsTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DetachVolumeOptionsTest.java deleted file mode 100644 index dd0680b..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DetachVolumeOptionsTest.java +++ /dev/null @@ -1,91 +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.DetachVolumeOptions.Builder.fromDevice; -import static org.jclouds.ec2.options.DetachVolumeOptions.Builder.fromInstance; -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 DetachVolumeOptions and DetachVolumeOptions.Builder.* - * - * @author Adrian Cole - */ -public class DetachVolumeOptionsTest { - - @Test - public void testAssignability() { - assert HttpRequestOptions.class.isAssignableFrom(DetachVolumeOptions.class); - assert !String.class.isAssignableFrom(DetachVolumeOptions.class); - } - - @Test - public void testFromDevice() { - DetachVolumeOptions options = new DetachVolumeOptions(); - options.fromDevice("test"); - assertEquals(options.buildFormParameters().get("Device"), ImmutableList.of("test")); - } - - @Test - public void testNullFromDevice() { - DetachVolumeOptions options = new DetachVolumeOptions(); - assertEquals(options.buildFormParameters().get("Device"), ImmutableList.of()); - } - - @Test - public void testFromDeviceStatic() { - DetachVolumeOptions options = fromDevice("test"); - assertEquals(options.buildFormParameters().get("Device"), ImmutableList.of("test")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testFromDeviceNPE() { - fromDevice(null); - } - - @Test - public void testFromInstance() { - DetachVolumeOptions options = new DetachVolumeOptions(); - options.fromInstance("test"); - assertEquals(options.buildFormParameters().get("InstanceId"), - ImmutableList.of("test")); - } - - @Test - public void testNullFromInstance() { - DetachVolumeOptions options = new DetachVolumeOptions(); - assertEquals(options.buildFormParameters().get("InstanceId"), ImmutableList.of()); - } - - @Test - public void testFromInstanceStatic() { - DetachVolumeOptions options = fromInstance("test"); - assertEquals(options.buildFormParameters().get("InstanceId"), - ImmutableList.of("test")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testFromInstanceNPE() { - fromInstance(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/RegisterImageBackedByEbsOptionsTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptionsTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptionsTest.java deleted file mode 100644 index 621fdf3..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptionsTest.java +++ /dev/null @@ -1,329 +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.RegisterImageBackedByEbsOptions.Builder.addBlockDeviceFromSnapshot; -import static org.jclouds.ec2.options.RegisterImageBackedByEbsOptions.Builder.addEphemeralBlockDeviceFromSnapshot; -import static org.jclouds.ec2.options.RegisterImageBackedByEbsOptions.Builder.addNewBlockDevice; -import static org.jclouds.ec2.options.RegisterImageBackedByEbsOptions.Builder.addNewEphemeralBlockDevice; -import static org.jclouds.ec2.options.RegisterImageBackedByEbsOptions.Builder.asArchitecture; -import static org.jclouds.ec2.options.RegisterImageBackedByEbsOptions.Builder.withDescription; -import static org.jclouds.ec2.options.RegisterImageBackedByEbsOptions.Builder.withKernelId; -import static org.jclouds.ec2.options.RegisterImageBackedByEbsOptions.Builder.withRamdisk; -import static org.testng.Assert.assertEquals; - -import org.jclouds.ec2.domain.Image.Architecture; -import org.jclouds.http.options.HttpRequestOptions; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMultimap; - -/** - * Tests possible uses of RegisterImageBackedByEbsOptions and - * RegisterImageBackedByEbsOptions.Builder.* - * - * @author Adrian Cole - */ -public class RegisterImageBackedByEbsOptionsTest { - - @Test - public void testAssignability() { - assert HttpRequestOptions.class.isAssignableFrom(RegisterImageBackedByEbsOptions.class); - assert !String.class.isAssignableFrom(RegisterImageBackedByEbsOptions.class); - } - - @Test - public void testWithDescription() { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - options.withDescription("test"); - assertEquals(options.buildFormParameters().get("Description"), - ImmutableList.of("test")); - } - - @Test - public void testNullWithDescription() { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - assertEquals(options.buildFormParameters().get("Description"), ImmutableList.of()); - } - - @Test - public void testWithDescriptionStatic() { - RegisterImageBackedByEbsOptions options = withDescription("test"); - assertEquals(options.buildFormParameters().get("Description"), - ImmutableList.of("test")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testWithDescriptionNPE() { - withDescription(null); - } - - @Test - public void testWithArchitecture() { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - options.asArchitecture(Architecture.I386); - assertEquals(options.buildFormParameters().get("Architecture"), - ImmutableList.of("i386")); - } - - @Test - public void testNullWithArchitecture() { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - assertEquals(options.buildFormParameters().get("Architecture"), ImmutableList.of()); - } - - @Test - public void testWithArchitectureStatic() { - RegisterImageBackedByEbsOptions options = asArchitecture(Architecture.I386); - assertEquals(options.buildFormParameters().get("Architecture"), - ImmutableList.of("i386")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testWithArchitectureNPE() { - asArchitecture(null); - } - - @Test - public void testWithKernelId() { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - options.withKernelId("test"); - assertEquals(options.buildFormParameters().get("KernelId"), ImmutableList.of("test")); - } - - @Test - public void testNullWithKernelId() { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - assertEquals(options.buildFormParameters().get("KernelId"), ImmutableList.of()); - } - - @Test - public void testWithKernelIdStatic() { - RegisterImageBackedByEbsOptions options = withKernelId("test"); - assertEquals(options.buildFormParameters().get("KernelId"), ImmutableList.of("test")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testWithKernelIdNPE() { - withKernelId(null); - } - - @Test - public void testWithRamdisk() { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - options.withRamdisk("test"); - assertEquals(options.buildFormParameters().get("RamdiskId"), - ImmutableList.of("test")); - } - - @Test - public void testNullWithRamdisk() { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - assertEquals(options.buildFormParameters().get("RamdiskId"), ImmutableList.of()); - } - - @Test - public void testWithRamdiskStatic() { - RegisterImageBackedByEbsOptions options = withRamdisk("test"); - assertEquals(options.buildFormParameters().get("RamdiskId"), - ImmutableList.of("test")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testWithRamdiskNPE() { - withRamdisk(null); - } - - @Test - public void testAddBlockDeviceFromSnapshot() { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - options.addBlockDeviceFromSnapshot("deviceName", "virtualName", "snapshotId"); - assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( - "BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false", - "BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName", - "virtualName", "BlockDeviceMapping.1.Ebs.SnapshotId", "snapshotId").entries()); - } - - @Test - public void testAddBlockDeviceFromSnapshotNullVirtualName() { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - options.addBlockDeviceFromSnapshot("deviceName", null, "snapshotId"); - assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( - "BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false", - "BlockDeviceMapping.1.DeviceName", "deviceName", - "BlockDeviceMapping.1.Ebs.SnapshotId", "snapshotId").entries()); - } - - @Test - public void testNullAddBlockDeviceFromSnapshot() { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - assertEquals(options.buildFormParameters(), ImmutableMultimap.<String, String> of()); - } - - @Test - public void testAddBlockDeviceFromSnapshotStatic() { - RegisterImageBackedByEbsOptions options = addBlockDeviceFromSnapshot("deviceName", - "virtualName", "snapshotId"); - assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( - "BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false", - "BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName", - "virtualName", "BlockDeviceMapping.1.Ebs.SnapshotId", "snapshotId").entries()); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testAddBlockDeviceFromSnapshotNPE() { - addBlockDeviceFromSnapshot(null, null, null); - } - - @Test - public void testAddEphemeralBlockDeviceFromSnapshot() { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - options.addEphemeralBlockDeviceFromSnapshot("deviceName", "virtualName", "snapshotId"); - assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( - "BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName", - "virtualName", "BlockDeviceMapping.1.Ebs.SnapshotId", "snapshotId").entries()); - } - - @Test - public void testAddEphemeralBlockDeviceFromSnapshotNullVirtualName() { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - options.addEphemeralBlockDeviceFromSnapshot("deviceName", null, "snapshotId"); - assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( - "BlockDeviceMapping.1.DeviceName", "deviceName", - "BlockDeviceMapping.1.Ebs.SnapshotId", "snapshotId").entries()); - } - - @Test - public void testNullAddEphemeralBlockDeviceFromSnapshot() { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - assertEquals(options.buildFormParameters(), ImmutableMultimap.<String, String> of()); - } - - @Test - public void testAddEphemeralBlockDeviceFromSnapshotStatic() { - RegisterImageBackedByEbsOptions options = addEphemeralBlockDeviceFromSnapshot("deviceName", - "virtualName", "snapshotId"); - assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( - "BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName", - "virtualName", "BlockDeviceMapping.1.Ebs.SnapshotId", "snapshotId").entries()); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testAddEphemeralBlockDeviceFromSnapshotNPE() { - addEphemeralBlockDeviceFromSnapshot(null, null, null); - } - - // ////// - @Test - public void testAddNewBlockDevice() { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - options.addNewBlockDevice("deviceName", "virtualName", 1); - assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( - "BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false", - "BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName", - "virtualName", "BlockDeviceMapping.1.Ebs.VolumeSize", "1").entries()); - } - - @Test - public void testAddNewBlockDeviceNullVirtualName() { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - options.addNewBlockDevice("deviceName", null, 1); - assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( - "BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false", - "BlockDeviceMapping.1.DeviceName", "deviceName", - "BlockDeviceMapping.1.Ebs.VolumeSize", "1").entries()); - } - - @Test - public void testNullAddNewBlockDevice() { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - assertEquals(options.buildFormParameters(), ImmutableMultimap.<String, String> of()); - } - - @Test - public void testAddNewBlockDeviceStatic() { - RegisterImageBackedByEbsOptions options = addNewBlockDevice("deviceName", "virtualName", 1); - assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( - "BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false", - "BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName", - "virtualName", "BlockDeviceMapping.1.Ebs.VolumeSize", "1").entries()); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testAddNewBlockDeviceNPE() { - addNewBlockDevice(null, null, 1); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testAddNewBlockDeviceTooBig() { - addNewBlockDevice("deviceName", "virtualName", 1025); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testAddNewBlockDeviceTooSmall() { - addNewBlockDevice("deviceName", "virtualName", 0); - } - - @Test - public void testAddNewEphemeralBlockDevice() { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - options.addNewEphemeralBlockDevice("deviceName", "virtualName", 1); - assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( - "BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName", - "virtualName", "BlockDeviceMapping.1.Ebs.VolumeSize", "1").entries()); - } - - @Test - public void testAddNewEphemeralBlockDeviceNullVirtualName() { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - options.addNewEphemeralBlockDevice("deviceName", null, 1); - assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( - "BlockDeviceMapping.1.DeviceName", "deviceName", - "BlockDeviceMapping.1.Ebs.VolumeSize", "1").entries()); - } - - @Test - public void testNullAddNewEphemeralBlockDevice() { - RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); - assertEquals(options.buildFormParameters(), ImmutableMultimap.<String, String> of()); - } - - @Test - public void testAddNewEphemeralBlockDeviceStatic() { - RegisterImageBackedByEbsOptions options = addNewEphemeralBlockDevice("deviceName", - "virtualName", 1); - assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of( - "BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName", - "virtualName", "BlockDeviceMapping.1.Ebs.VolumeSize", "1").entries()); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testAddNewEphemeralBlockDeviceNPE() { - addNewEphemeralBlockDevice(null, null, 1); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testAddNewEphemeralBlockDeviceTooBig() { - addNewEphemeralBlockDevice("deviceName", "virtualName", 1025); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testAddNewEphemeralBlockDeviceTooSmall() { - addNewEphemeralBlockDevice("deviceName", "virtualName", 0); - } -} 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/RegisterImageOptionsTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RegisterImageOptionsTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RegisterImageOptionsTest.java deleted file mode 100644 index 907c5ac..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RegisterImageOptionsTest.java +++ /dev/null @@ -1,146 +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.RegisterImageOptions.Builder.asArchitecture; -import static org.jclouds.ec2.options.RegisterImageOptions.Builder.withDescription; -import static org.jclouds.ec2.options.RegisterImageOptions.Builder.withKernelId; -import static org.jclouds.ec2.options.RegisterImageOptions.Builder.withRamdisk; -import static org.testng.Assert.assertEquals; - -import com.google.common.collect.ImmutableList; - -import org.jclouds.ec2.domain.Image.Architecture; -import org.jclouds.http.options.HttpRequestOptions; -import org.testng.annotations.Test; - -/** - * Tests possible uses of RegisterImageOptions and RegisterImageOptions.Builder.* - * - * @author Adrian Cole - */ -public class RegisterImageOptionsTest { - - @Test - public void testAssignability() { - assert HttpRequestOptions.class.isAssignableFrom(RegisterImageOptions.class); - assert !String.class.isAssignableFrom(RegisterImageOptions.class); - } - - @Test - public void testWithDescription() { - RegisterImageOptions options = new RegisterImageOptions(); - options.withDescription("test"); - assertEquals(options.buildFormParameters().get("Description"), - ImmutableList.of("test")); - } - - @Test - public void testNullWithDescription() { - RegisterImageOptions options = new RegisterImageOptions(); - assertEquals(options.buildFormParameters().get("Description"), ImmutableList.of()); - } - - @Test - public void testWithDescriptionStatic() { - RegisterImageOptions options = withDescription("test"); - assertEquals(options.buildFormParameters().get("Description"), - ImmutableList.of("test")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testWithDescriptionNPE() { - withDescription(null); - } - - @Test - public void testWithArchitecture() { - RegisterImageOptions options = new RegisterImageOptions(); - options.asArchitecture(Architecture.I386); - assertEquals(options.buildFormParameters().get("Architecture"), - ImmutableList.of("i386")); - } - - @Test - public void testNullWithArchitecture() { - RegisterImageOptions options = new RegisterImageOptions(); - assertEquals(options.buildFormParameters().get("Architecture"), ImmutableList.of()); - } - - @Test - public void testWithArchitectureStatic() { - RegisterImageOptions options = asArchitecture(Architecture.I386); - assertEquals(options.buildFormParameters().get("Architecture"), - ImmutableList.of("i386")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testWithArchitectureNPE() { - asArchitecture(null); - } - - @Test - public void testWithKernelId() { - RegisterImageOptions options = new RegisterImageOptions(); - options.withKernelId("test"); - assertEquals(options.buildFormParameters().get("KernelId"), ImmutableList.of("test")); - } - - @Test - public void testNullWithKernelId() { - RegisterImageOptions options = new RegisterImageOptions(); - assertEquals(options.buildFormParameters().get("KernelId"), ImmutableList.of()); - } - - @Test - public void testWithKernelIdStatic() { - RegisterImageOptions options = withKernelId("test"); - assertEquals(options.buildFormParameters().get("KernelId"), ImmutableList.of("test")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testWithKernelIdNPE() { - withKernelId(null); - } - - @Test - public void testWithRamdisk() { - RegisterImageOptions options = new RegisterImageOptions(); - options.withRamdisk("test"); - assertEquals(options.buildFormParameters().get("RamdiskId"), - ImmutableList.of("test")); - } - - @Test - public void testNullWithRamdisk() { - RegisterImageOptions options = new RegisterImageOptions(); - assertEquals(options.buildFormParameters().get("RamdiskId"), ImmutableList.of()); - } - - @Test - public void testWithRamdiskStatic() { - RegisterImageOptions options = withRamdisk("test"); - assertEquals(options.buildFormParameters().get("RamdiskId"), - ImmutableList.of("test")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testWithRamdiskNPE() { - withRamdisk(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/RunInstancesOptionsTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RunInstancesOptionsTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RunInstancesOptionsTest.java deleted file mode 100644 index f9c292a..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RunInstancesOptionsTest.java +++ /dev/null @@ -1,247 +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.RunInstancesOptions.Builder.asType; -import static org.jclouds.ec2.options.RunInstancesOptions.Builder.withBlockDeviceMappings; -import static org.jclouds.ec2.options.RunInstancesOptions.Builder.withKernelId; -import static org.jclouds.ec2.options.RunInstancesOptions.Builder.withKeyName; -import static org.jclouds.ec2.options.RunInstancesOptions.Builder.withRamdisk; -import static org.jclouds.ec2.options.RunInstancesOptions.Builder.withSecurityGroup; -import static org.jclouds.ec2.options.RunInstancesOptions.Builder.withUserData; -import static org.testng.Assert.assertEquals; - -import org.jclouds.ec2.domain.BlockDeviceMapping; -import org.jclouds.ec2.domain.InstanceType; -import org.jclouds.http.options.HttpRequestOptions; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; - -/** - * Tests possible uses of RunInstancesOptions and RunInstancesOptions.Builder.* - * - * @author Adrian Cole - */ -public class RunInstancesOptionsTest { - - @Test - public void testAssignability() { - assert HttpRequestOptions.class.isAssignableFrom(RunInstancesOptions.class); - assert !String.class.isAssignableFrom(RunInstancesOptions.class); - } - - @Test - public void testWithKeyName() { - RunInstancesOptions options = new RunInstancesOptions(); - options.withKeyName("test"); - assertEquals(options.buildFormParameters().get("KeyName"), ImmutableList.of("test")); - } - - @Test - public void testNullWithKeyName() { - RunInstancesOptions options = new RunInstancesOptions(); - assertEquals(options.buildFormParameters().get("KeyName"), ImmutableList.of()); - } - - @Test - public void testWithKeyNameStatic() { - RunInstancesOptions options = withKeyName("test"); - assertEquals(options.buildFormParameters().get("KeyName"), ImmutableList.of("test")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testWithKeyNameNPE() { - withKeyName(null); - } - - @Test - public void testWithSecurityGroup() { - RunInstancesOptions options = new RunInstancesOptions(); - options.withSecurityGroup("test"); - assertEquals(options.buildFormParameters().get("SecurityGroup.1"), ImmutableList.of("test")); - } - - @Test - public void testNullWithSecurityGroup() { - RunInstancesOptions options = new RunInstancesOptions(); - assertEquals(options.buildFormParameters().get("SecurityGroup"), ImmutableList.of()); - } - - @Test - public void testWithSecurityGroupStatic() { - RunInstancesOptions options = withSecurityGroup("test"); - assertEquals(options.buildFormParameters().get("SecurityGroup.1"), ImmutableList.of("test")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testWithSecurityGroupNPE() { - withSecurityGroup(null); - } - - @Test - public void testNullWithAdditionalInfo() { - RunInstancesOptions options = new RunInstancesOptions(); - assertEquals(options.buildFormParameters().get("AdditionalInfo"), ImmutableList.of()); - } - - @Test - public void testWithUserData() { - RunInstancesOptions options = new RunInstancesOptions(); - options.withUserData("test".getBytes()); - assertEquals(options.buildFormParameters().get("UserData"), ImmutableList.of("dGVzdA==")); - } - - @Test - public void testNullWithUserData() { - RunInstancesOptions options = new RunInstancesOptions(); - assertEquals(options.buildFormParameters().get("UserData"), ImmutableList.of()); - } - - @Test - public void testWithUserDataStatic() { - RunInstancesOptions options = withUserData("test".getBytes()); - assertEquals(options.buildFormParameters().get("UserData"), ImmutableList.of("dGVzdA==")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testWithUserDataNPE() { - withUserData(null); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testWithUserDataEmpty() { - withUserData("".getBytes()); - } - - @Test - public void testWithInstanceType() { - RunInstancesOptions options = new RunInstancesOptions(); - options.asType(InstanceType.C1_XLARGE); - assertEquals(options.buildFormParameters().get("InstanceType"), ImmutableList.of("c1.xlarge")); - } - - @Test - public void testNullWithInstanceType() { - RunInstancesOptions options = new RunInstancesOptions(); - assertEquals(options.buildFormParameters().get("InstanceType"), ImmutableList.of()); - } - - @Test - public void testWithInstanceTypeStatic() { - RunInstancesOptions options = asType(InstanceType.C1_XLARGE); - assertEquals(options.buildFormParameters().get("InstanceType"), ImmutableList.of("c1.xlarge")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testWithInstanceTypeNPE() { - asType(null); - } - - @Test - public void testWithKernelId() { - RunInstancesOptions options = new RunInstancesOptions(); - options.withKernelId("test"); - assertEquals(options.buildFormParameters().get("KernelId"), ImmutableList.of("test")); - } - - @Test - public void testNullWithKernelId() { - RunInstancesOptions options = new RunInstancesOptions(); - assertEquals(options.buildFormParameters().get("KernelId"), ImmutableList.of()); - } - - @Test - public void testWithKernelIdStatic() { - RunInstancesOptions options = withKernelId("test"); - assertEquals(options.buildFormParameters().get("KernelId"), ImmutableList.of("test")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testWithKernelIdNPE() { - withKernelId(null); - } - - @Test - public void testWithRamdisk() { - RunInstancesOptions options = new RunInstancesOptions(); - options.withRamdisk("test"); - assertEquals(options.buildFormParameters().get("RamdiskId"), ImmutableList.of("test")); - } - - @Test - public void testNullWithRamdisk() { - RunInstancesOptions options = new RunInstancesOptions(); - assertEquals(options.buildFormParameters().get("RamdiskId"), ImmutableList.of()); - } - - @Test - public void testWithRamdiskStatic() { - RunInstancesOptions options = withRamdisk("test"); - assertEquals(options.buildFormParameters().get("RamdiskId"), ImmutableList.of("test")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testWithRamdiskNPE() { - withRamdisk(null); - } - - @Test - public void testNullWithVirtualName() { - RunInstancesOptions options = new RunInstancesOptions(); - assertEquals(options.buildFormParameters().get("BlockDeviceMapping.VirtualName"), ImmutableList.of()); - } - - @Test - public void testWithBlockDeviceMapping() { - BlockDeviceMapping mapping = new BlockDeviceMapping.MapNewVolumeToDevice("/dev/sda1", 120, true); - RunInstancesOptions options = new RunInstancesOptions().withBlockDeviceMappings(ImmutableSet - .<BlockDeviceMapping> of(mapping)); - assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.DeviceName"), - ImmutableList.of("/dev/sda1")); - assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.VolumeSize"), - ImmutableList.of("120")); - assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.DeleteOnTermination"), - ImmutableList.of("true")); - } - - @Test - public void testNullWithBlockDeviceMapping() { - RunInstancesOptions options = new RunInstancesOptions(); - assertEquals(options.buildFormParameters().get("BlockDeviceMapping"), ImmutableList.of()); - } - - @Test - public void testWithBlockDeviceMappingStatic() { - BlockDeviceMapping mapping = new BlockDeviceMapping.MapNewVolumeToDevice("/dev/sda1", 120, true); - RunInstancesOptions options = withBlockDeviceMappings(ImmutableSet - .<BlockDeviceMapping> of(mapping)); - assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.DeviceName"), - ImmutableList.of("/dev/sda1")); - assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.VolumeSize"), - ImmutableList.of("120")); - assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.DeleteOnTermination"), - ImmutableList.of("true")); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testWithBlockDeviceMappingNPE() { - withBlockDeviceMappings(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/parse/DescribeSubnetsResponseTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/DescribeSubnetsResponseTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/DescribeSubnetsResponseTest.java deleted file mode 100644 index 7864015..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/DescribeSubnetsResponseTest.java +++ /dev/null @@ -1,71 +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.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.ec2.domain.Subnet; -import org.jclouds.ec2.xml.DescribeSubnetsResponseHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - * @author Andrew Bayer - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "DescribeSubnetsResponseTest") -public class DescribeSubnetsResponseTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/describe_subnets.xml"); - - FluentIterable<Subnet> expected = expected(); - - DescribeSubnetsResponseHandler handler = injector.getInstance(DescribeSubnetsResponseHandler.class); - FluentIterable<Subnet> result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - public FluentIterable<Subnet> expected() { - return FluentIterable.from(ImmutableSet.<Subnet>builder() - .add(Subnet.builder() - .subnetId("subnet-9d4a7b6c") - .subnetState(Subnet.State.AVAILABLE) - .vpcId("vpc-1a2b3c4d") - .cidrBlock("10.0.1.0/24") - .availableIpAddressCount(250) - .availabilityZone("us-east-1a") - .tag("Name", "ec2-o") - .tag("Empty", "") - .build()) - .add(Subnet.builder() - .subnetId("subnet-6e7f829e") - .subnetState(Subnet.State.AVAILABLE) - .vpcId("vpc-1a2b3c4d") - .cidrBlock("10.0.0.0/24") - .availableIpAddressCount(250) - .availabilityZone("us-east-1a") - .build()).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/parse/DescribeTagsResponseTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/DescribeTagsResponseTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/DescribeTagsResponseTest.java deleted file mode 100644 index 57157e9..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/DescribeTagsResponseTest.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.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.ec2.domain.Tag; -import org.jclouds.ec2.xml.DescribeTagsResponseHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "DescribeTagsResponseTest") -public class DescribeTagsResponseTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/describe_tags.xml"); - - FluentIterable<Tag> expected = expected(); - - DescribeTagsResponseHandler handler = injector.getInstance(DescribeTagsResponseHandler.class); - FluentIterable<Tag> result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - public FluentIterable<Tag> expected() { - return FluentIterable.from(ImmutableSet.<Tag>builder() - .add(Tag.builder() - .resourceId("i-5f4e3d2a") - .resourceType("instance") - .key("webserver") - .build()) - .add(Tag.builder() - .resourceId("i-5f4e3d2a") - .resourceType("instance") - .key("stack") - .value("Production") - .build()) - .add(Tag.builder() - .resourceId("i-12345678") - .resourceType("instance") - .key("database_server") - .build()) - .add(Tag.builder() - .resourceId("i-12345678") - .resourceType("instance") - .key("stack") - .value("Test") - .build()).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/parse/GetPasswordDataResponseTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/GetPasswordDataResponseTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/GetPasswordDataResponseTest.java deleted file mode 100644 index d29c852..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/GetPasswordDataResponseTest.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.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.date.DateService; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.ec2.domain.PasswordData; -import org.jclouds.ec2.xml.GetPasswordDataResponseHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -/** - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "GetPasswordDataResponseTest") -public class GetPasswordDataResponseTest extends BaseHandlerTest { - protected final DateService dateService = new SimpleDateFormatDateService(); - - public void test() { - InputStream is = getClass().getResourceAsStream("/get_passworddata.xml"); - - PasswordData expected = expected(); - - GetPasswordDataResponseHandler handler = injector.getInstance(GetPasswordDataResponseHandler.class); - PasswordData result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - } - - public PasswordData expected() { - return PasswordData.builder() - .instanceId("i-2574e22a") - .timestamp(dateService.iso8601DateParse("2012-07-30T07:27:23.000+0000")) - .passwordData("TGludXggdmVyc2lvbiAyLjYuMTYteGVuVSAoYnVpbGRlckBwYXRjaGJhdC5hbWF6b25zYSkgKGdj").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/predicates/VolumeDetachedTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/predicates/VolumeDetachedTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/predicates/VolumeDetachedTest.java deleted file mode 100644 index b5008ad..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/predicates/VolumeDetachedTest.java +++ /dev/null @@ -1,112 +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.predicates; - -import static com.google.common.collect.Sets.newHashSet; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - -import java.util.Date; -import java.util.Set; - -import org.jclouds.ec2.domain.Attachment; -import org.jclouds.ec2.domain.Attachment.Status; -import org.jclouds.ec2.domain.Volume; -import org.jclouds.ec2.features.ElasticBlockStoreApi; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/** - * @author Andrei Savu - */ -@Test(groups = "unit", singleThreaded = true) -public class VolumeDetachedTest { - - private ElasticBlockStoreApi client; - private VolumeDetached volumeDetached; - - @BeforeMethod - public void setUp() { - client = createMock(ElasticBlockStoreApi.class); - volumeDetached = new VolumeDetached(client); - } - - @Test - public void testVolumeWithEmptyListOfAttachments() { - Attachment attachment = newAttachmentWithStatus(Status.ATTACHED); - Set<Volume> volumes = newHashSet(newVolumeWithAttachments(/* empty */)); - - expect(client.describeVolumesInRegion(attachment.getRegion(), - attachment.getVolumeId())).andReturn(volumes); - replay(client); - - assertTrue(volumeDetached.apply(attachment)); - verify(client); - } - - @DataProvider(name = "notDetachedStatuses") - public Object[][] provideNotDetachedStatuses() { - return new Object[][] { - {Status.ATTACHED}, - {Status.ATTACHING}, - {Status.BUSY}, - {Status.DETACHING}, - {Status.UNRECOGNIZED} - }; - } - - @Test(dataProvider = "notDetachedStatuses") - public void testWithDifferentStatus(Status attachmentStatus) { - Attachment attachment = newAttachmentWithStatus(attachmentStatus); - Set<Volume> volumes = newHashSet(newVolumeWithAttachments(attachment)); - - expect(client.describeVolumesInRegion(attachment.getRegion(), - attachment.getVolumeId())).andReturn(volumes); - replay(client); - - assertFalse(volumeDetached.apply(attachment)); - verify(client); - } - - @Test - public void testWithStatusDetached() { - Attachment attachment = newAttachmentWithStatus(Status.DETACHED); - Set<Volume> volumes = newHashSet(newVolumeWithAttachments(attachment)); - - expect(client.describeVolumesInRegion(attachment.getRegion(), - attachment.getVolumeId())).andReturn(volumes); - replay(client); - - assertTrue(volumeDetached.apply(attachment)); - verify(client); - } - - private Volume newVolumeWithAttachments(Attachment... attachments) { - return Volume.builder().region("us-east-1").attachments(attachments).build(); - } - - private Attachment newAttachmentWithStatus(Status status) { - return Attachment.builder() - .volumeId("1").status(status).region("us-east-1").attachTime(new Date()) - .device("/dev/sda").instanceId("us-east-1/i-1234").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/suppliers/DescribeAvailabilityZonesInRegionTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegionTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegionTest.java deleted file mode 100644 index 8914805..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegionTest.java +++ /dev/null @@ -1,124 +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.suppliers; - -import static org.easymock.EasyMock.expect; -import static org.easymock.classextension.EasyMock.createControl; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; - -import java.util.Map; -import java.util.Set; - -import org.easymock.classextension.IMocksControl; -import org.jclouds.ec2.EC2Api; -import org.jclouds.ec2.domain.AvailabilityZoneInfo; -import org.jclouds.ec2.features.AvailabilityZoneAndRegionApi; -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpResponseException; -import org.testng.annotations.Test; - -import com.google.common.base.Optional; -import com.google.common.base.Suppliers; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; - -/** - * A test for {@link DescribeAvailabilityZonesInRegion}. - * - * @author Eric Pabst ([email protected]) - */ -public class DescribeAvailabilityZonesInRegionTest { - @Test - public void testDescribeAvailabilityZonesInRegion_BestEffort() { - IMocksControl control = createControl(); - EC2Api client = control.createMock(EC2Api.class); - AvailabilityZoneAndRegionApi regionClient = control.createMock(AvailabilityZoneAndRegionApi.class); - AvailabilityZoneInfo info1 = control.createMock(AvailabilityZoneInfo.class); - AvailabilityZoneInfo info2 = control.createMock(AvailabilityZoneInfo.class); - HttpCommand command = control.createMock(HttpCommand.class); - HttpResponseException exception = new HttpResponseException("Error: Unable to tunnel through proxy: ...", - command, null); - - expect(client.getAvailabilityZoneAndRegionApi()).andStubReturn((Optional) Optional.of(regionClient)); - expect(regionClient.describeAvailabilityZonesInRegion("accessibleRegion1")).andReturn( - ImmutableSet.of(info1)); - expect(regionClient.describeAvailabilityZonesInRegion("inaccessibleRegion")).andThrow(exception); - expect(regionClient.describeAvailabilityZonesInRegion("accessibleRegion2")).andReturn( - ImmutableSet.of(info2)); - expect(info1.getZone()).andStubReturn("zone1"); - expect(info2.getZone()).andStubReturn("zone2"); - - Set<String> regions = ImmutableSet.of("accessibleRegion1", "inaccessibleRegion", "accessibleRegion2"); - control.replay(); - - Map<String, Set<String>> expectedResult = ImmutableMap.<String, Set<String>> builder().put("accessibleRegion1", - ImmutableSet.of("zone1")).put("accessibleRegion2", ImmutableSet.of("zone2")).build(); - - DescribeAvailabilityZonesInRegion regionIdToZoneId = new DescribeAvailabilityZonesInRegion(client, Suppliers - .ofInstance(regions)); - assertEquals(Maps.transformValues(regionIdToZoneId.get(), Suppliers.<Set<String>> supplierFunction()), - expectedResult); - control.verify(); - } - - @Test - public void testDescribeAvailabilityZonesInRegion_RethrowIfNoneFound() { - IMocksControl control = createControl(); - EC2Api client = control.createMock(EC2Api.class); - AvailabilityZoneAndRegionApi regionClient = control.createMock(AvailabilityZoneAndRegionApi.class); - HttpCommand command = control.createMock(HttpCommand.class); - HttpResponseException exception = new HttpResponseException("Error: Unable to tunnel through proxy: ...", - command, null); - - expect(client.getAvailabilityZoneAndRegionApi()).andStubReturn((Optional) Optional.of(regionClient)); - expect(regionClient.describeAvailabilityZonesInRegion("inaccessibleRegion")).andThrow(exception); - - Set<String> regions = ImmutableSet.of("inaccessibleRegion"); - control.replay(); - - DescribeAvailabilityZonesInRegion regionIdToZoneId = new DescribeAvailabilityZonesInRegion(client, Suppliers - .ofInstance(regions)); - try { - regionIdToZoneId.get(); - fail("expected exception"); - } catch (HttpResponseException e) { - assertEquals(e, exception); - } - control.verify(); - } - - @Test - public void testDescribeAvailabilityZonesInRegion_NoZones() { - IMocksControl control = createControl(); - EC2Api client = control.createMock(EC2Api.class); - AvailabilityZoneAndRegionApi regionClient = control.createMock(AvailabilityZoneAndRegionApi.class); - - expect(client.getAvailabilityZoneAndRegionApi()).andStubReturn((Optional) Optional.of(regionClient)); - expect(regionClient.describeAvailabilityZonesInRegion("emptyRegion")).andReturn( - ImmutableSet.<AvailabilityZoneInfo> of()); - - Set<String> regions = ImmutableSet.of("emptyRegion"); - control.replay(); - - DescribeAvailabilityZonesInRegion regionIdToZoneId = new DescribeAvailabilityZonesInRegion(client, Suppliers - .ofInstance(regions)); - assertEquals(regionIdToZoneId.get(), ImmutableMap.<String, String> of()); - control.verify(); - } -} 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/util/IpPermissionsTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/util/IpPermissionsTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/util/IpPermissionsTest.java deleted file mode 100644 index 242bf59..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/util/IpPermissionsTest.java +++ /dev/null @@ -1,106 +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.util; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.net.domain.IpProtocol; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * Tests possible uses of IpPermissions - * - * @author Adrian Cole - */ -@Test(testName = "IpPermissionsTest") -public class IpPermissionsTest { - public void testAllProtocol() { - IpPermissions authorization = IpPermissions.permitAnyProtocol(); - assertEquals( - IpPermissions.buildFormParametersForIndex(0, authorization).toString(), - "{IpPermissions.0.IpProtocol=[-1], IpPermissions.0.FromPort=[1], IpPermissions.0.ToPort=[65535], IpPermissions.0.IpRanges.0.CidrIp=[0.0.0.0/0]}"); - } - - public void testAllProtocolCidrBound() { - IpPermissions authorization = IpPermissions.permit(IpProtocol.ALL).originatingFromCidrBlock("1.1.1.1/32"); - assertEquals( - IpPermissions.buildFormParametersForIndex(0, authorization).toString(), - "{IpPermissions.0.IpProtocol=[-1], IpPermissions.0.FromPort=[1], IpPermissions.0.ToPort=[65535], IpPermissions.0.IpRanges.0.CidrIp=[1.1.1.1/32]}"); - } - - public void testJustProtocolAndCidr() { - IpPermissions authorization = IpPermissions.permit(IpProtocol.TCP).originatingFromCidrBlock("1.1.1.1/32"); - assertEquals( - IpPermissions.buildFormParametersForIndex(0, authorization).toString(), - "{IpPermissions.0.IpProtocol=[tcp], IpPermissions.0.FromPort=[1], IpPermissions.0.ToPort=[65535], IpPermissions.0.IpRanges.0.CidrIp=[1.1.1.1/32]}"); - } - - public void testAnyProtocol() { - IpPermissions authorization = IpPermissions.permitAnyProtocol().originatingFromCidrBlock("1.1.1.1/32"); - assertEquals( - IpPermissions.buildFormParametersForIndex(0, authorization).toString(), - "{IpPermissions.0.IpProtocol=[-1], IpPermissions.0.FromPort=[1], IpPermissions.0.ToPort=[65535], IpPermissions.0.IpRanges.0.CidrIp=[1.1.1.1/32]}"); - } - - public void testMultipleCidrs() { - IpPermissions authorization = IpPermissions.permit(IpProtocol.TCP).originatingFromCidrBlocks( - ImmutableSet.of("1.1.1.1/32", "1.1.1.2/32")); - assertEquals( - IpPermissions.buildFormParametersForIndex(0, authorization).toString(), - "{IpPermissions.0.IpProtocol=[tcp], IpPermissions.0.FromPort=[1], IpPermissions.0.ToPort=[65535], IpPermissions.0.IpRanges.0.CidrIp=[1.1.1.1/32], IpPermissions.0.IpRanges.1.CidrIp=[1.1.1.2/32]}"); - } - - public void testProtocolFromAndToPortAndGroupIds() { - IpPermissions authorization = IpPermissions.permit(IpProtocol.UDP).fromPort(11).to(53) - .originatingFromSecurityGroupId("groupId"); - assertEquals( - IpPermissions.buildFormParametersForIndex(0, authorization).toString(), - "{IpPermissions.0.IpProtocol=[udp], IpPermissions.0.FromPort=[11], IpPermissions.0.ToPort=[53], IpPermissions.0.Groups.0.GroupId=[groupId]}"); - } - - public void testProtocolICMPAny() { - IpPermissions authorization = IpPermissions.permitICMP().originatingFromSecurityGroupId("groupId"); - assertEquals( - IpPermissions.buildFormParametersForIndex(0, authorization).toString(), - "{IpPermissions.0.IpProtocol=[icmp], IpPermissions.0.FromPort=[-1], IpPermissions.0.ToPort=[-1], IpPermissions.0.Groups.0.GroupId=[groupId]}"); - } - - public void testProtocolICMPTypeAnyCode() { - IpPermissions authorization = IpPermissions.permitICMP().type(8).originatingFromSecurityGroupId("groupId"); - assertEquals( - IpPermissions.buildFormParametersForIndex(0, authorization).toString(), - "{IpPermissions.0.IpProtocol=[icmp], IpPermissions.0.FromPort=[8], IpPermissions.0.ToPort=[-1], IpPermissions.0.Groups.0.GroupId=[groupId]}"); - } - - public void testProtocolICMPTypeCode() { - IpPermissions authorization = IpPermissions.permitICMP().type(8).andCode(0) - .originatingFromSecurityGroupId("groupId"); - assertEquals( - IpPermissions.buildFormParametersForIndex(0, authorization).toString(), - "{IpPermissions.0.IpProtocol=[icmp], IpPermissions.0.FromPort=[8], IpPermissions.0.ToPort=[0], IpPermissions.0.Groups.0.GroupId=[groupId]}"); - } - - public void testProtocolFromAndToPortAndUserGroups() { - IpPermissions authorization = IpPermissions.permit(IpProtocol.ICMP).originatingFromUserAndSecurityGroup("userId", - "groupId"); - assertEquals( - IpPermissions.buildFormParametersForIndex(0, authorization).toString(), - "{IpPermissions.0.IpProtocol=[icmp], IpPermissions.0.FromPort=[-1], IpPermissions.0.ToPort=[-1], IpPermissions.0.Groups.0.UserId=[userId], IpPermissions.0.Groups.0.GroupId=[groupId]}"); - } -} 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/util/TagsTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/util/TagsTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/util/TagsTest.java deleted file mode 100644 index 5a4af14..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/util/TagsTest.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.util; - -import static org.jclouds.ec2.domain.Tag.ResourceType.IMAGE; -import static org.jclouds.ec2.domain.Tag.ResourceType.INSTANCE; -import static org.testng.Assert.assertEquals; - -import org.jclouds.ec2.domain.Tag; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ -@Test -public class TagsTest { - Tag resourceTag1 = Tag.builder().resourceType(IMAGE).resourceId("1").key("key").value("value").build(); - - public void testValueFunction() { - assertEquals(Tags.valueFunction().apply(resourceTag1), "value"); - } - - public void testKeyFunction() { - assertEquals(Tags.keyFunction().apply(resourceTag1), "key"); - } - - Tag resourceTag2 = Tag.builder().resourceType(IMAGE).resourceId("1").key("foo").value("bar").build(); - Tag resource2Tag1 = Tag.builder().resourceType(INSTANCE).resourceId("2").key("absent").build(); - Tag resource2Tag2 = Tag.builder().resourceType(INSTANCE).resourceId("2").key("hello").value("world").build(); - - public void testResourceToTagsAsMap() { - assertEquals( - Tags.resourceToTagsAsMap(ImmutableSet.of(resourceTag1, resourceTag2, resource2Tag1, resource2Tag2)), - ImmutableMap.of("1", ImmutableMap.of("key", "value", "foo", "bar"), - "2", ImmutableMap.of("absent", "", "hello", "world"))); - } - -} 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/AllocateAddressResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/AllocateAddressResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/AllocateAddressResponseHandlerTest.java deleted file mode 100644 index 2e0980f..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/AllocateAddressResponseHandlerTest.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.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.UnknownHostException; - -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code AllocateAddressResponseHandler} - * - * @author Adrian Cole - */ -//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "AllocateAddressResponseHandlerTest") -public class AllocateAddressResponseHandlerTest extends BaseHandlerTest { - public void testApplyInputStream() throws UnknownHostException { - - InputStream is = getClass().getResourceAsStream("/allocate_address.xml"); - - String result = factory.create(injector.getInstance(AllocateAddressResponseHandler.class)) - .parse(is); - - assertEquals(result, "67.202.55.255"); - } -} 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/AttachmentHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/AttachmentHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/AttachmentHandlerTest.java deleted file mode 100644 index 1555ffe..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/AttachmentHandlerTest.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.Attachment; -import org.jclouds.http.functions.ParseSax; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code AttachmentHandler} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "AttachmentHandlerTest") -public class AttachmentHandlerTest extends BaseEC2HandlerTest { - public void testApplyInputStream() { - DateService dateService = injector.getInstance(DateService.class); - InputStream is = getClass().getResourceAsStream("/attach.xml"); - - Attachment expected = new Attachment(defaultRegion, "vol-4d826724", "i-6058a509", "/dev/sdh", - Attachment.Status.ATTACHING, dateService.iso8601DateParse("2008-05-07T11:51:50.000Z")); - - AttachmentHandler handler = injector.getInstance(AttachmentHandler.class); - addDefaultRegionToHandler(handler); - Attachment 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/BaseEC2HandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/BaseEC2HandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/BaseEC2HandlerTest.java deleted file mode 100644 index 4bc0550..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/BaseEC2HandlerTest.java +++ /dev/null @@ -1,86 +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 java.util.Map; -import java.util.Set; - -import javax.inject.Singleton; - -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.Zone; -import org.jclouds.util.Suppliers2; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Provides; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public abstract class BaseEC2HandlerTest extends BaseHandlerTest { - protected String defaultRegion = Region.US_EAST_1; - - @BeforeTest - @Override - protected void setUpInjector() { - injector = Guice.createInjector(new SaxParserModule(), new AbstractModule() { - - @Override - protected void configure() { - - } - - @Singleton - @Provides - @org.jclouds.location.Region - Supplier<String> provideDefaultRegion() { - return Suppliers.ofInstance(defaultRegion); - } - - @Singleton - @Provides - @Zone - Supplier<Map<String, Supplier<Set<String>>>> provideRegionToAvailabilityZoneMap() { - return Suppliers.<Map<String, Supplier<Set<String>>>> ofInstance(Maps.transformValues(ImmutableMap - .<String, Set<String>> of("us-east-1", ImmutableSet.of("us-east-1a")), Suppliers2 - .<Set<String>> ofInstanceFunction())); - } - - @Singleton - @Provides - @Zone - Supplier<Set<String>> provideZones() { - return Suppliers.<Set<String>> ofInstance(ImmutableSet.of("us-east-1a")); - } - }); - factory = injector.getInstance(ParseSax.Factory.class); - assert factory != 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/xml/BlockDeviceMappingHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/BlockDeviceMappingHandlerTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/BlockDeviceMappingHandlerTest.java deleted file mode 100644 index 097feae..0000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/BlockDeviceMappingHandlerTest.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.util.Map; - -import org.jclouds.date.DateService; -import org.jclouds.ec2.domain.Attachment; -import org.jclouds.ec2.domain.BlockDevice; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; - -/** - * Tests behavior of {@code BlockDeviceMappingHandler} - * - * @author Adrian Cole - */ -//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "BlockDeviceMappingHandlerTest") -public class BlockDeviceMappingHandlerTest extends BaseHandlerTest { - public void testApplyInputStream() { - - InputStream is = getClass().getResourceAsStream( - "/describe_image_attribute_blockDeviceMapping.xml"); - - DateService dateService = injector.getInstance(DateService.class); - Map<String, BlockDevice> expected = ImmutableMap.<String, BlockDevice> of("/dev/sda1", - new BlockDevice("vol-d74b82be", Attachment.Status.ATTACHED, dateService - .iso8601DateParse("2010-02-20T18:25:26.000Z"), true), "/dev/sdf", - new BlockDevice("vol-another", Attachment.Status.DETACHED, dateService - .iso8601DateParse("2010-02-20T19:26:26.000Z"), false)); - - Map<String, BlockDevice> result = factory.create( - injector.getInstance(BlockDeviceMappingHandler.class)).parse(is); - - assertEquals(result, expected); - } -}
