You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ni...@apache.org on 2014/04/02 11:14:16 UTC
[04/25] forking jclouds ec2 api
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..7626c61
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DescribeImagesOptionsTest.java
@@ -0,0 +1,134 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..d4d4c00
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DescribeSnapshotsOptionsTest.java
@@ -0,0 +1,129 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..dd0680b
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DetachVolumeOptionsTest.java
@@ -0,0 +1,91 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..621fdf3
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptionsTest.java
@@ -0,0 +1,329 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..907c5ac
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RegisterImageOptionsTest.java
@@ -0,0 +1,146 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..f9c292a
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RunInstancesOptionsTest.java
@@ -0,0 +1,247 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..7864015
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/DescribeSubnetsResponseTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..57157e9
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/DescribeTagsResponseTest.java
@@ -0,0 +1,74 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..d29c852
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/GetPasswordDataResponseTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..b5008ad
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/predicates/VolumeDetachedTest.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.ec2.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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..8914805
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegionTest.java
@@ -0,0 +1,124 @@
+/*
+ * 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 (pabstec@familysearch.org)
+ */
+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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..242bf59
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/util/IpPermissionsTest.java
@@ -0,0 +1,106 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..5a4af14
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/util/TagsTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..2e0980f
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/AllocateAddressResponseHandlerTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..1555ffe
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/AttachmentHandlerTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..4bc0550
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/BaseEC2HandlerTest.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.ec2.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/incubator-stratos/blob/58fe66df/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
new file mode 100644
index 0000000..097feae
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/BlockDeviceMappingHandlerTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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);
+ }
+}